Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static String getEncryptedLink(String sLink) {
- Blob cipherText = Crypto.encryptWithManagedIV('AES256', getKey(),
- Blob.valueOf(sLink));
- String encodedCipherText = EncodingUtil.convertToHex(cipherText);
- return EncodingUtil.urlEncode(encodedCipherText,'UTF-8') ;
- }
- }
- static String getPlainLink(String sEncryptedLink) {
- String sCleanLink = EncodingUtil.urlDecode(sEncryptedLink,'UTF-8');
- Blob encodedEncryptedBlob = EncodingUtil.convertFromHex(sCleanLink);
- Blob decryptedBlob = Crypto.decryptWithManagedIV('AES256', getKey(),
- encodedEncryptedBlob);
- String decryptedClearText = decryptedBlob.toString();
- return decryptedClearText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement