646
Chapter 3: ColdFusion Functions
Usage
The result of this function is useful for comparison and validation. For example, you can store the
hash of a password in a database without exposing the password. You can check the validity of the
password by hashing the entered password and comparing the result with the hashed password in
the database.
ColdFusion MX 7 uses the Java Cryptography Extension (JCE) and installs a Sun Java 1.4.2
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, Macromedia cannot provide technical support for third-
party security providers.
The
encoding
attrbute is normally not required. It provides a mechanism for generating identical
hash values on systems with different default encodings. ColdFusion uses a default encoding of
UTF-8 unless you modify the defaultCharset entry in the neo-runtime.xml file.
Example
The following example lets you enter a password and compares the hashed password with a hash
value saved in the SecureData table of the cfdocexamples database. This table has the following
three entries:
<h3>Hash Example</h3>
<!--- Do the following if the form is submitted. --->
<cfif IsDefined("Form.UserID")>
<!--- query the data base. --->
<cfquery name = "CheckPerson" datasource = "cfdocexamples">
SELECT PasswordHash
FROM SecureData
WHERE UserID = <cfqueryparam value = "#Form.userID#"
cfsqltype = "CF_SQL_CHARVAR">
</cfquery>
<!--- Compare query PasswordHash field and the hashed form password
and display the results. --->
<cfoutput>
<cfif Hash(Form.password, "SHA") is not checkperson.passwordHash>
User ID #Form.userID# or password is not valid. Try again.
<cfelse>
Password is valid for User ID #Form.userID#.
</cfif>
</cfoutput>
</cfif>
User ID
Password
12
abc
14
def
15
ghi
Summary of Contents for COLFUSION MX 7 - INSTALLING AND USING COLDFUSION MX
Page 1: ...COLDFUSION MX7 CFML Reference...
Page 20: ...20 Chapter 1 Reserved Words and Variables...
Page 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...
Page 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...
Page 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...
Page 411: ...cftable 411 cftable body html...
Page 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...
Page 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...
Page 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...
Page 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...
Page 664: ...664 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...
Page 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...
Page 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 903: ...Val 903 value Is the beginning numeric name form...
Page 932: ...932 Chapter 3 ColdFusion Functions...
Page 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...
Page 962: ...962 Chapter 5 Application CFC Reference...
Page 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...