Creates a secret encryption key that can be used with the encrypt() and decrypt() functions.
generateSecretKey([algorithm] [,keysize])
→ returns string
AESAESBLOWFISHDESDESEDE128192256512Generate a secret key and use it to encrypt and decrypt a message.
message = "Top Secret";
// Generate AES secret key
secretKey = generateSecretKey("AES", 256);
// Encrypt the message
encryptedText = encrypt(message, secretKey, "AES", "Base64");
// Decrypt the message
decryptedText = decrypt(encryptedText, secretKey, "AES", "Base64");
writeDump({
encrypted = encryptedText,
decrypted = decryptedText
});
Expected Result: Displays the encrypted and decrypted message.
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.