Skip to content

Instantly share code, notes, and snippets.

@shinux
Created June 6, 2016 09:34
Show Gist options
  • Save shinux/324ca9fec39c336a9219f3a09bdeeb40 to your computer and use it in GitHub Desktop.
Save shinux/324ca9fec39c336a9219f3a09bdeeb40 to your computer and use it in GitHub Desktop.
import crypto from 'crypto';
function gen(password) {
const randomSalt = crypto.randomBytes(16).toString('base64');
const bufferSalt = new Buffer(randomSalt, 'base64');
const hashPassword = crypto.pbkdf2Sync(password, bufferSalt, 10000, 64).toString('base64');
console.log('salt', randomSalt);
console.log('password', hashPassword);
return (randomSalt, hashPassword);
}
export default {
gen,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment