Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { promisify } = require('util');
- const { randomBytes, pbkdf2 } = require('crypto');
- const generateRandomBytes = promisify(randomBytes);
- const hashPassword = promisify(pbkdf2);
- const _ = {
- async hashPassword(args){
- const { pw } = args;
- const salt = (args.salt || await generateRandomBytes(64)).toString('hex');
- const iter = (args.iter || await this.generateRandomInt(1024)) + 10000;
- const hash = await hashPassword(pw, salt, iter, 64, 'sha512').toString('hex');
- return `${hash}:${salt}:${iter}`;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement