Case Sensitive passwords
How to create Case Sensitive passwords in ColdFusion?
This is done by using the Compare function.
The Compare function performs a case-sensitive comparison of two strings and returns:
-1 if string1 is less then string2
0 if string1 is equal to string2
1 if string is greater then string2
Let?s try this on a simple login form.
login.cfm
<form action="login_act.cfm" method="post">
Username: <input type="text" name="username" value="" />
<br />
Password: <input type="password" name="password" value="" />
<br />
<input type="submit" name="login" value="Log In" />
<br />
</form>
login_act.cfm
<!--- Here we hardtype the password. You can easy read it from a database instead. --->
<cfset sectret_password = "0AbcD">
<!--- We use the Compare function and check for case sensitive --->
<cfset comparing = Compare(FORM.password, sectret_password)>
<!--- Testing the returned value of comparing --->
<cfif comparing eq 0>
If "0" (string1 is equal to string2), user OK. Can Log In.
<cfelse>
<!--- String1 and string2 are NOT equal, NOT a valid Case Sensitive password. --->
<!--- Send user back to Log IN form or something else. --->
</cfif>
Now you easy can create a better security in ur ColdFusion application.
Advertisement

No User Comments.
No User Comments, be the first one to write your comments?


