Skip to content

Instantly share code, notes, and snippets.

@virtix
Created June 24, 2009 10:47
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/135149 to your computer and use it in GitHub Desktop.
Save virtix/135149 to your computer and use it in GitHub Desktop.
<cffunction name="computeHash" access="public" returntype="String">
<cfargument name="password" type="string" />
<cfargument name="salt" type="string" />
<cfargument name="iterations" type="numeric" required="false" default="1024" />
<cfargument name="algorithm" type="string" required="false" default="SHA-512" />
<cfscript>
var hashed = '';
var i = 1;
hashed = hash( password & salt, arguments.algorithm, 'UTF-8' );
for (i = 1; i <= iterations; i++) {
hashed = hash( hashed & salt, arguments.algorithm, 'UTF-8' );
}
return hashed;
</cfscript>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment