Whatever message this page gives is out now! Go check it out!
hash(string [, algorithm [, encoding] [,outputEncoding] [, iterations ]])Parameter | Description |
string | String to hash . |
algorithm | (Optional) The algorithm to use to hash the string. ColdFusion installs a cryptography library with the following algorithms:
|
The Enterprise Edition of ColdFusion installs the RSA BSafe Crypto-J library, which provides FIPS-140 Compliant Strong Cryptography. It includes the following algorithms:
| |
encoding | (Optional; to use this attribute, also specify the algorithm parameter) A string specifying the encoding to use when converting the string to byte data used by the hash algorithm. Must be a character encoding name recognized by the Java runtime. The default value is the value specified by the defaultCharset entry in the neo-runtime. xml file, which is normally UTF-8. Ignored when using the CFMX_COMPAT algorithm. |
| outputEncoding | Represents the format or representation of the hash value (also known as the hash digest) that is produced after the hashing algorithm processes the input data. The possible values are:
|
iterations | (Optional) The number of times to iterate hashing, to increase hash computation time. CF10+. ColdFusion considers number of iterations after hashing the given value. Hence, this parameter is the number of iterations + 1. The default number of additional iterations is 0. |
User ID | Password |
blaw | blaw |
dknob | dknob |
<cfscript>
// SHA-256 example
writeOutput(hash("an important string", "SHA-256", "UTF-8"))
// 4825D8AB22800A9BE09986366D6430CA8E704323E4470608AC303A9F1C05626F
// SHA-512 example
writeOutput(hash("an important string", "SHA-512", "UTF-8"))
//06B24506B66BA5DA743CC8E2F67977C212379FCE7FF8F3BB99AC7A2A0C053D595B1A4077E9C9346453A95067BCED38338920DF8CC85F4ED3313A7039D37DFCD7
</cfscript><cfscript>
// String to hash
originalString = "MySecretMessage";
// Hash using SHA-384
hashedString = hash(originalString, "SHA-384");
// Output the hashed string
writeOutput("Original String: " & originalString & "<br>");
writeOutput("SHA-384 Hashed String: " & hashedString);
</cfscript><cfscript>
string="This is a string to be encoded."
writeOutput(hash(string=string, algorithm="SHA-256", encoding="UTF-8",outputEncoding="hex"))
</cfscript><cfscript>
string="This is a string to be encoded."
writeOutput(hash(string=string, algorithm="SHA-256", encoding="UTF-8",outputEncoding="base64"))
</cfscript><cfscript>
string="This is a string to be encoded."
writeOutput(hash(string=string, algorithm="SHA-256", encoding="UTF-8",outputEncoding="base64url"))
</cfscript>