Skip to content

Instantly share code, notes, and snippets.

@brucekirkpatrick
Created November 10, 2013 23:00
Show Gist options
  • Save brucekirkpatrick/7405099 to your computer and use it in GitHub Desktop.
Save brucekirkpatrick/7405099 to your computer and use it in GitHub Desktop.
Using scrypt hashing in coldfusion or railo
<cfscript>
password="test1234";
N = 65536; // CPU cost parameter.
r = 16; // Memory cost parameter.
p = 1; // Parallelization parameter.
// Note: SCryptUtil has default of 16 byte random salt and 256-bit key
SCryptUtil=createobject("java", "com.lambdaworks.crypto.SCryptUtil", "/path/to/scrypt-1.4.0.jar");
// generate a hash
hashedPassword=SCryptUtil.scrypt(password, N, r, p);
// verify the password
result=SCryptUtil.check(password, hashedPassword);
// do custom handling of the result
if(result){
writeoutput("password matched");
}else{
writeoutput("password doesn't match");
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment