MACROMEDIA COLFUSION MX 7-CFML Reference page 593

Cfml reference
Hide thumbs Also See for COLFUSION MX 7-CFML:
Table of Contents

Advertisement

Example
The following example encrypts and decrypts a text string. It lets you specify the encryption
algorithm and encoding technique. It also has a field for a key seed to use with the
CFMX_COMPAT algorithm. For all other algorithms, it uses the
to generate a secret key.
<h3>Decrypt Example</h3>
<!--- Do the following if the form has been submitted. --->
<cfif IsDefined("Form.myString")>
<cfscript>
/* GenerateSecretKey does not generate keys for the CFMX_COMPAT algorithm,
so we use a key from the form.
*/
if (Form.myAlgorithm EQ "CFMX_COMPAT")
theKey=Form.MyKey;
// For all other encryption techniques, generate a secret key.
else
theKey=generateSecretKey(Form.myAlgorithm);
//Encrypt the string.
encrypted=encrypt(Form.myString, theKey, Form.myAlgorithm,
Form.myEncoding);
//Decrypt it.
decrypted=decrypt(encrypted, theKey, Form.myAlgorithm, Form.myEncoding);
</cfscript>
<!--- Display the values used for encryption and decryption,
and the results. --->
<cfoutput>
<b>The algorithm:</b> #Form.myAlgorithm#<br>
<b>The key:</B> #theKey#<br>
<br>
<b>The string:</b> #Form.myString# <br>
<br>
<b>Encrypted:</b> #encrypted#<br>
<br>
<b>Decrypted:</b> #decrypted#<br>
</cfoutput>
</cfif>
<!--- The input form. --->
<form action="#CGI.SCRIPT_NAME#" method="post">
<b>Select the encoding</b><br>
<select size="1" name="myEncoding" >
<option selected>UU</option>
<option>Base64</option>
<option>Hex</option>
</select><br>
<br>
<b>Select the algorithm</b><br>
<select size="1" name="myAlgorithm" >
<option selected>CFMX_COMPAT</option>
<option>AES</option>
<option>DES</option>
GenerateSecretKey
GenerateSecretKey
function
593

Advertisement

Table of Contents
loading

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents