Skip to content

Instantly share code, notes, and snippets.

@virtix
Created June 24, 2009 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtix/135150 to your computer and use it in GitHub Desktop.
Save virtix/135150 to your computer and use it in GitHub Desktop.
<!-------------------------------------------------------------------------
Assume a login form with username and pasword:
form.user_id and form.password
-------------------------------------------------------------------------->
<cfquery name="loginQuery" datasource="users" maxrows="1">
SELECT password_hash, salt
FROM USERS where user_id = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#form.user_id#" maxlength="12" />
</cfquery>
<cfset hashedFormPassword = crypto.computeHash(form.password, loginQuery.salt) />
<cfif loginQuery.password_hash eq hashedFormPassword>
Valid user.
<cfelse>
Invalid user.
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment