User Guide
578 Chapter 3: ColdFusion Functions
Encrypt
Description
Encrypts a string using a specific algorithm and encoding method.
Returns
String; can be much longer than the original string.
Category
Security functions, String functions
Function syntax
Encrypt(string, key[, algorithm[, encoding]]))
See also
Decrypt
History
ColdFusion MX 7: Added the algorithm and encoding parameters.
Parameters
Parameter Description
string String to encrypt.
key String. Key or seed used to encrypt the string.
• For the CFMX_COMPAT algorithm, any combination of any number of
characters; used as a seed used to generate a 32-bit encryption key.
• For all other algorithms, a key in the format used by the algorithm. For these
algorithms, use the
GenerateSecretKey function to generate the key.
algorithm (Optional) The algorithm to use to decrypt the string.ColdFusion MX installs a
cryptography library with the following algorithms:
• CFMX_COMPAT: the algorithm used in ColdFusion MX and prior releases. This
algorithm is the least secure option (default).
• 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.
If you install a security provider with additional cryptography algorithms, you can
also specify any of its string encryption and decryption algorithms.
encoding (Optional; if you specify this parameter, you must also specify the
algorithm
parameter) The binary encoding in which to represent the data as a string.
• Base64: the Base64 algorithm, as specified by IETF RFC 2045.
• Hex: the characters !-F0-9 represent the hexadecimal byte values.
• UU: the UUEncode algorithm (default).