Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/91d698331db35da7d84e27dcd32b1632 to your computer and use it in GitHub Desktop.
Save trycf/91d698331db35da7d84e27dcd32b1632 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
// Use a 16-byte (128-bit) AES key
key = "12345678901234567890123456789012"; // 16 characters
// Text to encrypt
originalText = "kiosk";
// Encrypt the text (returns Base64 string)
encryptedBinary = encrypt(originalText, key, "AES", "Base64");
// Decrypt using ToString(ToBinary()) (works only for simple round-trip)
decryptedText = ToString(ToBinary(encryptedBinary));
// Or safer: use the decrypt() function
safeDecrypted = decrypt(encryptedBinary, key, "AES", "Base64");
// Output
writeOutput("Original Text: " & originalText & "<br>");
writeOutput("Encrypted (Base64): " & encryptedBinary & "<br>");
writeOutput("Decrypted via ToString(toBinary()): " & decryptedText & "<br>");
writeOutput("Decrypted via decrypt(): " & safeDecrypted);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment