bcrypt nodejs hash password

Hello readers! In this article I have shared the details about “bcrypt nodejs hash password”. Okay, let’s move on to the tutorial.

bcrypt nodejs hash password

 bcrypt.genSalt(saltRounds, (err, salt) => 
    bcrypt.hash(yourPassword, salt, (err, hash) => 
       console.log(salt + hash)

	var bcrypt = dcodeIO.bcrypt; 

    /** One way, can't decrypt but can compare */
    var salt = bcrypt.genSaltSync(10);

    /** Encrypt password */
    bcrypt.hash('anypassword', salt, (err, res) => 
        console.log('hash', res)
        hash = res

    /** Compare stored password with new encrypted password */
    function compare(encrypted) 
        bcrypt.compare('aboveusedpassword', encrypted, (err, res) => 
            // res == true or res == false
            console.log('Compared result', res, hash) 

// If u want do the same with NodeJS use this:
/*		var bcrypt = require('bcryptjs')	*/

Final Thoughts

I hope this article helps you to know about “bcrypt nodejs hash password”. If you have any doubts regarding this article please let us know via the comment section. Share this article with your friends and family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment