Skip to content

Instantly share code, notes, and snippets.

@tzmfreedom
Created June 7, 2016 01:33
Show Gist options
  • Save tzmfreedom/725a3d38e90f47191181fa458e681545 to your computer and use it in GitHub Desktop.
Save tzmfreedom/725a3d38e90f47191181fa458e681545 to your computer and use it in GitHub Desktop.
Encryption/Decription for apex
Blob cryptoKey = Crypto.generateAesKey(128);
Blob iv = Blob.valueOf('0123456789012345');
System.debug(EncodingUtil.base64encode(cryptoKey));
Blob data = Blob.valueOf('TestTest');
Blob encryptedData = Crypto.encrypt('AES128', cryptoKey, iv, data);
System.debug(EncodingUtil.base64encode(encryptedData));
//Blob decryptedData = Crypto.decrypt('AES128', cryptoKey, encryptedData);
//System.debug(decryptedData.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment