I don't understand how using a random salt for hashing passwords can work. Perhaps random salt refers to something other than hashing passwords? Here is my thought process:
The salt is used to add extra junk to the end of a password prior to hashing it, to fight against the likelihood of being cracked by a rainbow table
However to ensure you can still verify a password is correct, you must use the same salt for each password prior to encrypting it to see if it matches the hash saved for a certain user
If a random salt is used, how can that password ever be verified again?
I don't store generated random salt in my database, still I am able to verify the password hash.
How is it possible?
I am taking below example mentioned on bcryptjs npm module
//auto-gen a salt and hash:
var hash = bcrypt.hashSync('bacon', 10);
//compare hash
const validPass = bcrypt.compareSync('bacon', hash)
It works, It verifyfies the password, but How?
Update
I got some insight from here. If still someone could explain better that would be helpful.