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
var crypto = require('crypto'); | |
// larger numbers mean better security, less | |
var config = { | |
// size of the generated hash | |
hashBytes: 32, | |
// larger salt means hashed passwords are more resistant to rainbow table, but | |
// you get diminishing returns pretty fast | |
saltBytes: 16, | |
// more iterations means an attacker has to take longer to brute force an |
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
var Promise = require('bluebird'); | |
var crypto = Promise.promisifyAll(require("crypto")); | |
// http://security.stackexchange.com/questions/110084/parameters-for-pbkdf2-for-password-hashing | |
var config = { | |
hashBytes : 64, // size of the generated hash (to be chosen accordint the the chosen algo) | |
saltBytes : 16, // sise of the salt : larger salt means hashed passwords are more resistant to rainbow table | |
iterations : 500000, // tune so that hashing the password takes about 1 second | |
algo :'sha512', | |
encoding : 'base64' // hex is readable but base64 is shorter |