Every time I use:
BCrypt.HashPassword(password, 12)
it gives me different output. From what I've read, in order to check log-in details, I must have password itself:
BCrypt.Verify(expectedPassword , hashed);
So I'm confused: I thought I should keep in my DB only the hashes, not the passwords themselves. What am I missing ?
You are 100% correct when you state:
Following on from our online chat, where we clarified the issue you were querying, the general process is as follows:
Later on ...
The important thing to note is that, for a given hash algorithm, two identical strings will always hash to identical values, so this comparison is safe.
It is standard to allow the password to be in plain text when still in memory. It is in theory possible to encrypt it before it reaches the server (for example, it would not surprise me if there exist SHA-512 procedures written in JavaScript to hash passwords before they are submitted), but that generally is above and beyond even the most complex security requirements.