Converts a variable-length string to a 32-byte, hexadecimal string, using the MD5 algorithm. (It is not possible to convert the hash result back to the source string.)
Conversion functions, Other functions, String functions
Hash(string)
| Parameter | Description |
|---|---|
| string |
A string or a variable that contains one. |
The result is useful for comparison and validation. For example, a developer can store the hash of a password in a database without exposing the password. The developer can check the validity of the password with the following code:
<cfif hash(form.password) is not myQuery.passwordHash>
<cflocation url = "unauthenticated.cfm"> </cfif>
<!--- How to use Hash for password validation. This assumes that UserID
value is passed to this page with a URL parameter. --->
<h3>Hash Example</h3>
<cfquery name = "CheckPerson" datasource = "UserData">
SELECT PasswordHash
FROM SecureData
WHERE UserID = <cfqueryparam value = "#UserID#"
cfsqltype = "CF_SQL_CHARVAR">
</cfquery>
<cfif Hash(form.password) is not checkperson.passwordHash>
<cflocation url = "unauthenticated.cfm">
<cfelse>
...
</cfif>
ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6
Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt1113.htm
Comments
grizzlychicken said on Nov 12, 2003 at 2:49 PM : Zuchachass said on Nov 20, 2003 at 9:12 AM : ThisIsMe said on Feb 20, 2004 at 1:47 PM :