Created
November 10, 2013 23:00
-
-
Save brucekirkpatrick/7405099 to your computer and use it in GitHub Desktop.
Using scrypt hashing in coldfusion or railo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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