Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. static String getEncryptedLink(String sLink) {
  2. Blob cipherText = Crypto.encryptWithManagedIV('AES256', getKey(),
  3. Blob.valueOf(sLink));
  4. String encodedCipherText = EncodingUtil.convertToHex(cipherText);
  5. return EncodingUtil.urlEncode(encodedCipherText,'UTF-8') ;
  6. }
  7. }
  8.  
  9. static String getPlainLink(String sEncryptedLink) {
  10. String sCleanLink = EncodingUtil.urlDecode(sEncryptedLink,'UTF-8');
  11. Blob encodedEncryptedBlob = EncodingUtil.convertFromHex(sCleanLink);
  12. Blob decryptedBlob = Crypto.decryptWithManagedIV('AES256', getKey(),
  13. encodedEncryptedBlob);
  14. String decryptedClearText = decryptedBlob.toString();
  15. return decryptedClearText;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement