Created
April 20, 2017 23:48
-
-
Save mattmahn/6edac174b0e7ab85b5cba5461cc67673 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
const crypto = require('crypto'); | |
const NUM = 3e5; | |
function SnH(password, salt) { | |
return new Promise((resolve) => { | |
let originalSalt = salt; | |
password = Buffer.from(password); | |
salt = Buffer.from(salt); | |
console.time('hashinate'); | |
let hash = crypto.createHash('sha256').update(Buffer.concat([password, salt])).digest('hex'); | |
for (let i = 0; i < NUM; i++) { | |
hash = crypto.createHash('sha256').update(Buffer.concat([salt, Buffer.from(hash, 'hex')])).digest('hex'); | |
// hash = algo.update(Buffer.concat([salt, Buffer.from(hash.digest('hex'))])); | |
} | |
console.timeEnd('hashinate'); | |
resolve({ | |
hash, | |
salt: originalSalt | |
}); | |
}); | |
} | |
SnH('password', 'what about the BaBIES?!?!?').then(({ salt, hash }) => { | |
console.log(`salt: ${salt}`); | |
console.log(`hash: ${hash}`); | |
}).catch(err => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment