Created
May 4, 2018 06:36
-
-
Save Yang03/741465d1f4364e4037e08dd6735fc550 to your computer and use it in GitHub Desktop.
nodejs
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 passwordDigest(str, password) { | |
// digest = base64 ( sha1 ( nonce + created + password ) ) | |
var pwHash = crypto.createHash('sha1'); | |
// var rawNonce = new Buffer(nonce || '', 'base64').toString('binary'); | |
var s = str.concat(shaPwd(password)); | |
pwHash.update(s); | |
var str = new Buffer(pwHash.digest()).toString('base64'); | |
console.log(str); | |
return str; | |
}; | |
function shaPwd(password) { | |
var sha1 = crypto.createHash('sha1'); | |
sha1.update(password); | |
var temp = sha1.digest().toString(); | |
console.log(temp) | |
return temp; | |
} | |
// console.log(hashPwd); | |
var str = 'B1F97FA2-278C-4C23-84E7-9B0A2B128723' + '2018-05-03T08:58:07:705Z' | |
console.log(passwordDigest(str, 'Ab97Jr5')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment