我不确定您使用的是哪个版本,但这似乎适用于 CF9、OpenBD 和 Railo(使用 AES 或 Blowfish)
<!--- create an encrypted cookie --->
<cfset text = "testing, 1, 2, 3" >
<cfset key = generateSecretKey("AES")>
<cfset encrypted = encrypt(text, key, "AES", "hex")>
<cfcookie name="secretValue" value="#encrypted#">
<!--- display test values used--->
<form method="post">
DEBUG:<hr />
<cfoutput>
Text: #text#<br />
Key: #key#<br />
Encrypted: #encrypted# <br />
<input type="hidden" name="text" value="#text#">
<input type="hidden" name="key" value="#key#">
<input type="submit" value="Decrypt Cookie">
</cfoutput>
</form>
<!--- decrypt test values --->
<cfif structKeyExists(FORM, "key") AND structKeyExists(COOKIE, "secretValue")>
<cfset decrypted = decrypt(cookie.secretValue, key, "AES", "hex") >
<cfoutput>
form.text = #text# <br />
form.key = #key# <br />
cookie.secretValue = #cookie.secretValue# <br />
decrypted = #decrypted# <br />
</cfoutput>
</cfif>