How to encrypt a string using a specific algorithm and encoding method in ColdFusion

Encrypt() - encrypt a string using a specific algorithm and encoding method

Encrypt.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Encrypt function example: how to encrypt a string using a specific algorithm and encoding method</title>
</head>

<body>
<h2 style="color:Crimson">Encrypt Function Example</h2>
<cfset TestString="This is a string">
<cfset SecretKey=GenerateSecretKey("DESEDE")>
<cfset EncryptString=Encrypt(TestString,SecretKey)>

<cfoutput>
<b>TestString:</b> #TestString#
<br />
<b>TestString[after encrypt]:</b> #EncryptString#
<br />
<b>TestString[after decrypt]:</b> #Decrypt(EncryptString,SecretKey)#
</cfoutput>
</body>
</html>





More ColdFusion examples