You need to sign in to do that
Don't have an account?
AES128 encryption using Crypto.encryptWithManagedIV
I'm trying to construct a url in a controller and one of the parameters need to be AES128 encrypted, and then urlencoded. I've been given a base64encoded key to use, and I'm attempting to use Crypto.encryptWithManagedIV class to encrypt the param like so:
Blob encryptionKey = EncodingUtil.base64Decode('xxxxxxxxxxxxxxxxxx');
String payloadStr = 'text to be encoded';
Blob payload = Blob.valueof(payloadStr);
Blob encryptedPayload = Crypto.encryptWithManagedIV('AES128', encryptionKey, payload);
myUrl = 'http://www.mysite.com/myPage.aspx?a=' + EncodingUtil.urlEncode(encryptedPayload.Tostring(),'UTF-8');
The error I'm getting is Invalid private key. Must be 16 bytes.
How many bytes does your encryption key contains?