How to use the bcryptjs.encodeBase64 function in bcryptjs

To help you get started, we’ve selected a few bcryptjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProtonMail / WebClient / src / app / authentication / services / passwords.js View on Github external
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;
    }
github ProtonMail / WebClient / src / app / authentication / services / passwords.js View on Github external
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));
            });
        },
github kantium / pmpkpe / index.js View on Github external
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));
}

bcryptjs

Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.

MIT
Latest version published 7 years ago

Package Health Score

73 / 100
Full package analysis