When the user creates a password, I transfer it (including salt) and save it in the database.
Now that the user wants to change his password, I want to check if the new one is too similar to the old one (I saw this in different services, especially in the online bank).
So, I thought I would use a similar_text or levenshtein . And this works if the user must enter their old password.
But when the user forgot his password, and they need to reset it, obviously, you do not need to enter your old password. Therefore, I will need to compare the new password with the old password (stored in the database), which I do not have in the normal text, but a hash.
Now, when I use the new password using the same salt and compare it with the old password (hashed), I obviously cannot check if the new and old password are similar.
I'm just curious to know how companies do this when they donβt save the password as plain text in the database?
I could not find anything useful on Google. If anyone has suggestions or links to articles that discuss this in more detail, I would appreciate it if they could share them.
source share