Generate a salt and hash on separate function callsīcrypt.genSalt(saltRounds, (err, salt) => ) īoth the ways mentioned above can also be achieved with promises, these methods ( hash & compare) will return a Promise when a callback is not defined.īcrypt also provides methods like genSaltSync, HashSync and CompareSync to perform synchronously.So, there are two ways to hash a password: Implementation const bcrypt = require('bcrypt') const saltRounds = 10 const yourPassword = "someRandomPasswordHere" For example, a cost factor of n means that the calculation will be done 2^n times. Higher the salt rounds, the more hashing rounds are done, hence the time and difficulty is increased while brute-forcing. Salt Rounds: This is the cost factor that indicates the amount of time needed to calculate a single bcrypt hash. The table illustrates the relation of salt value the hashed value
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |