Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var hash_password = function(plaintext) {
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync(plaintext, salt);
return hash;
};
exports.encryptSync = function(password){
var algo = AppProperties.get("PASSWORD_ENC_ALGO");
if (algo == BCRYPT) {
var bcrypt = require('bcrypt-nodejs');
var salt = bcrypt.genSaltSync(10);
return bcrypt.hashSync(password, salt);
}
else {
return getSHA1Hash(password);
}
};
function hashPassword (instance) {
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync(instance.password, salt);
instance.password = hash;
}
public generateToken() {
const secret = `${this.username}${this.email}${Date.now()}`;
const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
this.authToken = new AuthToken(token, refreshToken);
}
public generateToken() {
const secret = `${this.username}${this.email}${Date.now()}`;
const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
this.authToken = new AuthToken(token, refreshToken);
}