Whatever message this page gives is out now! Go check it out!

GenerateSecretKey

Last update:
May 18, 2026

Description

Gets a secure key value for use in the  Encrypt  function.

Returns

A string that contains the encryption key.

Category

Function syntax

GenerateSecretKey(algorithm [,keysize])

See also

History

ColdFusion 8: Added the  keysize  parameter.
ColdFusion MX 7: Added this function.

Parameters

ParameterDescription
algorithm
The encryption algorithm for which to generate the key. ColdFusion installs a cryptography library with the following algorithms:
  • AES: the Advanced Encryption Standard specified by the National Institute of Standards and Technology (NIST) FIPS-197.
  • BLOWFISH: the Blowfish algorithm defined by Bruce Schneier.
  • DES: the Data Encryption Standard algorithm defined by NIST FIPS-46-3.
  • DESEDE: the "Triple DES" algorithm defined by NIST FIPS-46-3.
keysize
Number of bits requested in the key for the specified algorithm. You can use this to request longer keys when allowed by the JDK. For example, the AES algorithm keys are limited to 256 bits unless the Java Unlimited Strength Jurisdiction Policy Files are installed. For more information, see http://java.sun.com/products/jce/index-14.html .

Usage

You cannot use the GenerateSecretKey function to generate a key for the ColdFusion default encryption algorithm (CFMX_COMPAT) of the  Encrypt and  Decrypt  functions. ColdFusion uses the Java Cryptography Extension (JCE) and installs a Sun Java 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, Adobe cannot provide technical support for third-party security providers.

Example

<cfscript>
   myAESKey=generateSecretKey(("AES"),256)
   writeOutput(myAESKey) // XNAJxwjyuCBlpGGbXygWSaxoMd7Dfb1oFdP+JBeyTOs=
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page