XXTEA encryption / decryption for Monkey

Monkey Forums/Monkey Code/XXTEA encryption / decryption for Monkey

Pharmhaus(Posted 2014) [#1]
This is the XXTEA function ported to Monkey.
EDIT: OK, simplistic string support is now given. It uses the databuffer to bypass encoding/decoding of strings.



Small example that i used for testing:

Strict

Import "xxtea.monkey"

Function Main:Int()
	Local ar:Int[1024]
	Local k:=[123, 456, 769, 123]
	ar[15] = 12345
	XXTea.btea(ar, (ar.Length - 1), k)
	Print ar[15]
	XXTea.btea(ar, - (ar.Length - 1), k)
	Print ar[15]
	
	
	Print XXTea.DecryptString(XXTea.EncryptString("Hello world, how are you ?", k), k)
	Return 0
End





Supertino(Posted 2014) [#2]
Always nice to have, though strings for me would be more useful. Thanks for this,


Pharmhaus(Posted 2014) [#3]
Will this do it for you?
It's not 'real' string support because it uses the Databuffer but it should work as long as you use a binary format.