Decrypts encrypted binary data with the specified key, value, algorithm, salt, and iterations.
Unencrypted binary data.
Security functions, String functions
DecryptBinary(bytes, key[,algorithm[, IVorSalt[, iterations]]])
ColdFusion MX 7 Updater: Added the function.
| Parameter | Description |
|---|---|
|
bytes |
Binary data to decrypt. |
|
key |
String. For the CFMX_COMPAT algorithm, the seed that was used to encrypt the binary data; for all other algorithms, the string generated by the |
|
algorithm |
(Optional) The algorithm to use to decrypt the data. Must be the same as the algorithm used to encrypt the binary data. ColdFusion MX installs a cryptography library with the following algorithms:
If you install a security provider with additional cryptography algorithms, you can also specify any of its string encryption and decryption algorithms. |
|
IVorSalt |
(Optional) Specify this parameter to adjust ColdFusion encryption to match the details of other encryption software. If you specify this parameter, you must also specify the
|
|
iterations |
(Optional) The number of iterations to transform the password into a binary key. Specify this parameter to adjust ColdFusion encryption to match the details of other encryption software. If you specify this parameter, you must also specify the |
This function uses a symmetric key-based algorithm, in which the same key is used to encrypt and decrypt data. The parameter values must match the values used to encode the string. The security of the encrypted string depends on maintaining the secrecy of the key.
ColdFusion MX 7 Updater uses the Java Cryptography Extension (JCE) and installs a Sun Java 1.4.2 runtime that includes the Sun JCE default security provider. This provider includes the algorithms listed in the Parameters section. The JCE framework includes facilities for using other provider implementations; however, Macromedia cannot provide technical support for third-party security providers.
<h3>DecryptBinary Example</h3>
< !--- Do the following if the form has been submitted. --->
<cfif IsDefined("Form.myfile")>
<cffile file="#Form.myfile#" action="readBinary" variable="myData">
<cfscript>
/* GenerateSecretKey does not generate key for the CFMX_COMPAT algorithm,
so use the 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=encryptBinary(myData, theKey, Form.myAlgorithm);
//Decrypt it
decrypted=decryptBinary(encrypted, theKey, Form.myAlgorithm);
</cfscript>
<cfset encfile="#Form.myfile#" & "_enc">
<cfset decfile="#Form.myfile#" & "_dec">
<cffile file="#encfile#" action="write" output="#encrypted#">
<cffile file="#decfile#" action="write" output="#decrypted#">
<!--- 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 InputFile:</b> #Form.myfile# <br>
<br>
<b>Encrypted:</b> #encfile#<br>
<br>
<b>Decrypted:</b> #decfile#<br>
</cfoutput>
</cfif>
<!--- The input form. --->
<form action="#CGI.SCRIPT_NAME#" method="post">
<b>Select the algorithm</b><br>
<select size="1" name="myAlgorithm">
<option selected>CFMX_COMPAT</option>
<option>AES</option>
<option>DES</option>
<option>DESEDE</option>
</select><br>
<br>
<b>Input your key</b> (used for CFMX_COMPAT encryption only)<br>
<input type = "Text" name = "myKey" value = "MyKey"><br>
<br>
<b>Enter filename to encrypt</b><br>
<input type="text" name="myfile" value="Enter the path of the file to encrypt"><br>
<input type = "Submit" value = "Encrypt file ">
</form>
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting
Version 7
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00001829.htm