| Contents > CFML Reference > ColdFusion Functions > Hash |
|
|
|
|
||
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.)
32-byte, hexadecimal 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>
|
|
||
| Contents > CFML Reference > ColdFusion Functions > Hash |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. 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.1/htmldocs/funct113.htm
Comments
frinky!!! said on May 17, 2004 at 6:05 AM : Ike23 said on Sep 3, 2004 at 2:11 PM : deepu_verma said on Sep 10, 2004 at 12:20 AM : oneishy_ said on Sep 10, 2004 at 10:02 AM : webdev101 said on Sep 10, 2004 at 11:24 AM : KiraganJeff said on Sep 27, 2004 at 12:01 PM : pete_freitag said on Jan 25, 2005 at 12:16 PM : No screen name said on Jan 31, 2005 at 6:21 AM : paulfeakins said on Jul 8, 2005 at 10:31 AM :