Every day removes MD5 for its problems in the context of password storage. But what about usage, when I just want to add an authentication level to what is likely to be used once?
This is just a hypothetical example, but let me say that I have a function that allows the user to reset their password. I email the user a link that they can click to set a new (randomly generated) password.
My real thinking is that I will create an MD5 hash using the value of the private salt and a pair of identifying variables, and use this to create the link.
Let's say the salt for this function is "8b769a378411b705" (I use the same salt for all reset password requests). Other identifying pieces of data are the user identifier and the database identifier of the password hashes already generated.
salt = "8b769a378411b705" (private) user_id = 123 pw_id = 456 code = md5(salt + " " + user_id + " " + pw_id)
which becomes
code = "692a71cd7da194145be209e40fcd3e92"
link example: confirm_reset_password.php? user_id = 123 & pw_id = 456 & code = 692a71cd7da194145be209e40fcd3e92
Is this considered safe in light of problems with MD5? Is there any other one-way hash I should use, like SHA-1?
I use PBKDF2 with SHA1 to store passwords, and I understand that part of its benefit lies in its โsluggishnessโ and how long it takes to generate hashes. I could generate these better hashes for purposes like this, but I think this can have unpleasant consequences, as you can easily put the server on its knees, bombarding it with requests (incorrect), since each of them leads to a significant CPU task to generate a hash (especially since I use a lot of iterations). It seems that having a โfastโ algorithm is suitable for single-use, but I wonder if MD5 remains the best choice.
Thanks!
security md5 sha1
DivideByHero
source share