Created
May 17, 2012 00:09
-
-
Save mountainpenguin/2715068 to your computer and use it in GitHub Desktop.
my hash function
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
| function getToken() { | |
| return Math.floor( (new Date().getTime() / 1000) / 10 ); | |
| } | |
| function genSalt() { | |
| var salt = new String(); | |
| for (i=0; i<10; i++) { | |
| var r = Math.floor( Math.random() * 128 ); | |
| salt += String.fromCharCode(r); | |
| } | |
| return salt; | |
| } | |
| function hashPassword(pw) { | |
| var new_salt = genSalt(); | |
| var token = getToken(); | |
| var token_salt = CryptoJS.SHA256(token + new_salt); | |
| var hashed1 = CryptoJS.SHA256(pw); | |
| var hashed2 = CryptoJS.SHA256(pw + token_salt); | |
| return "$" + new_salt + "$" + hashed2; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment