Hashing passwords with bcrypt

  • by
const bcrypt = require('bcrypt')

const myFunction = async () => {
  const password = "Res123456!"
  const hashedPassword = await bcrypt.hash(password, 12)

  console.log(password)
  console.log(hashedPassword)

  const isMatch = await bcrypt.compare("Res123456", hashedPassword)
  console.log(isMatch)
}

myFunction()

Hashing

From hashes you cant reverse the process and get the plain text password. Hashes are meant to work only in one direction.

pa$sW0rd -> fdsmakc675dfas -\>  pa$sW0rd 

Encryption algorithm

Is reversable.

 pa$sW0rd -> fdsmakc675dfas ->  pa$sW0rd  
Tags: