fork download
  1. public class EncryptData {
  2. public static String encrypt(String plainText) {
  3. Blob key = Blob.valueOf('1234567890123456'); // Example key (use a proper key management system)
  4. Blob data = Blob.valueOf(plainText);
  5. Blob encryptedData = Crypto.encryptWithManagedIV('AES256', key, data);
  6. return EncodingUtil.base64Encode(encryptedData);
  7. }
  8.  
  9. public static String decrypt(String encryptedText) {
  10. Blob key = Blob.valueOf('1234567890123456');
  11. Blob encryptedData = EncodingUtil.base64Decode(encryptedText);
  12. Blob decryptedData = Crypto.decryptWithManagedIV('AES256', key, encryptedData);
  13. return decryptedData.toString();
  14. }
  15. }
Success #stdin #stdout #stderr 0.01s 8964KB
stdin
1
2
10
42
11
stdout
Object: UndefinedObject error: did not understand #EncryptData
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #EncryptData (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:2: parse error, expected '}'