Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function computeKeyPassword(password, salt) {
if (salt && salt.length) {
const saltBinary = binaryStringToArray(decodeBase64(salt));
return bcryptHelper(password, '$2y$10$' + bcrypt.encodeBase64(saltBinary, 16)).then((hash) => {
// Remove bcrypt prefix and salt (first 29 characters)
return hash.slice(29);
});
}
// No salt, old-style
const deferred = $q.defer();
deferred.resolve(password);
return deferred.promise;
}
3(password, salt, modulus) {
const saltBinary = binaryStringToArray(salt + 'proton');
// We use the latest version of bcrypt, 2y, with 2^10 rounds.
return bcryptHelper(password, '$2y$10$' + bcrypt.encodeBase64(saltBinary, 16)).then((unexpandedHash) => {
return expandHash(unexpandedHash + arrayToBinaryString(modulus));
});
},
let getPassword = function(KeySalt, MailboxPassword) {
const saltBinary = binaryStringToArray(atob(KeySalt.trim()));
var hash = bcryptjs.hashSync(MailboxPassword.trim(), '$2y$10$' + bcryptjs.encodeBase64(saltBinary, 16));
console.log(hash.slice(29));
}