I am trying to use roEVPCipher method to encrypt my data using aes-128-ecb cipher,
But Its failing in initial setup only, Setup returns error code as -1
cipher_obj = CreateObject("roEVPCipher")
ret = cipher_obj.Setup(true, "aes-128-ecb", "0123456789abcdef", "", 0)
if ret <> 0
print "Setup Error" ; ret
end if
The similar code is working properly for blowfish cipher encryption
cipher_obj = CreateObject("roEVPCipher")
ret = cipher_obj.Setup(true, "bf", "7B1CB530521E7554D623E1412A2CF29F", "785BC65A9D7850FD", 0)
if ret <> 0
print "Setup Error" ; ret
end if
Please suggest me, how to use aes-128-ecb cipher encryption
I am unable to figure out how to use AES 128 encryption. Roku box keeps rebooting in most of the attempts. Otherwise, setup call returns -1. It is working perfectly fine if I use “bf”.
Appreciate your help.
here is my code snippet:
alg = "aes-128-cbc"
'alg = "bf"
pad = 1
encryptKey = "10a58869d74be5a374cf867cfb473859"
IV = "00000000000000000000000000000000"
plainText = "00000000000000000000000000000000"
encResult = crypto_encrypt(alg, encryptKey, IV, plainText, pad)
Function crypto_encrypt(alg as String, encryptKey As String, IV As String, text As String, pad as Integer) As String
crypto = CreateObject("roEVPCipher")
res = crypto.Setup(true, alg,encryptKey,IV,pad)
print res
ba = CreateObject("roByteArray")
ba.FromAsciiString(text)
enc = crypto.Process(ba)
return (enc.ToHexString())
End function
“manuthepassion” wrote:
Thanks Guys, Now its working fine with 128 bit hex encoded key
How were you able to encode your ascii string to a 128-bit hex key? I’ve been creating a roByteArray from ascii and then outputting a hex string, but I’m not getting my roEVPCipher setup yet…