[code] #The key, it must be an hex encoded key
$key = pack(‘H*’, $_POST[‘key’]);
#The text that will be encrypted
$plaintext = $_POST['decrypted'];
#With this I get the encrypted value
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext, MCRYPT_MODE_ECB);
# encode into hex
$ciphertext_hex = bin2hex($ciphertext);[/code]
into XOJO using the MBS encryption kit.
I wrote this:
[code] dim ciph As CipherMBS
ciph = CipherMBS.aes_128_ecb
dim cKey As MemoryBlock = “mykey”
dim data As String = “mydata”
ciph.EncryptInit(cKey)
dim output As String
output = ciph.ProcessString(data) + ciph.FinalizeAsString
output = EncodeHex(output)
[/code]
In both cases I use
key="5350d786e90956e915fa5e9ea09d5346"
data="grandemax"
But I get,
ouput="4b3cf39f8861d8c8f634eb26c68bfa1a" 'in the fisrt case
ouput="4EFE8E8379F5F26233C866AE314161C8" 'in the second one.
Any of you have any idea in order to fix that?
In need the PHP result into XOJO too.
Thanks to everyone.
I haven’t tested but an alternative that might be faster:
dim data as MemoryBlock = "grandemax"
data.Size = ciph.BlockSize
This should work since a MemoryBlock will automatically convert to a nil-encoded String, and a String will automatically convert to a MemoryBlock. Resizing the MemoryBlock upward will pad it with nulls.