How to saving salt

Issue

maybe, in the signup process,
( I using express.js, MySQL, Sequelize )

  1. get ID and PW at Front-end
  2. saving ID in DB
  3. hashing the pw with salt
  4. save hashed pw in DB

And,,,
can I use salt used before?

when some user log-in this server,
their PW will be hashing and compair with DB data.
but salt is just random..
so I wanna save salt value!

Solution

If you’re using bcrypt

const salt = bcrypt.genSaltSync(12)
// Continue whatever user saving happens here with salt

Other libraries may also have these functions, generate a salt, use it as the parameter of hashing

Answered By – MTN

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published