Everyone is shooting down MD5 these days for its issues in the context of storing passwords. But what about uses where I just want to add a layer of authentication to something that will likely be used once?
This is just a hypothetical example, but let's say I have a feature to allow a user to reset their password. I email the user a link that they can click to set a new (randomly-generated) password.
My current thinking is that I'll generate an MD5 hash, using a private salt value, and a couple of identifying variables, and use that to create the link.
Let's say the salt for this feature is "8b769a378411b705" (I use the same salt for all reset password requests). The other identifying pieces of data are the user ID and a database ID of the already-generated password hashes.
salt = "8b769a378411b705" (private)
user_id = 123
pw_id = 456
code = md5(salt + " " + user_id + " " + pw_id)
which becomes
code = "692a71cd7da194145be209e40fcd3e92"
example link: confirm_reset_password.php?user_id=123&pw_id=456&code=692a71cd7da194145be209e40fcd3e92
Is this considered safe, in light of the issues with MD5? Is there another one-way hash I should consider using, like SHA-1?
I've been using PBKDF2 with SHA1 for storing passwords, and I understand that part of its benefit is in its "slowness" and how long it takes to generate hashes. I could generate those higher-quality hashes for purposes like this, but I think it can backfire, since you could easily bring a server to its knees by bombarding it with (incorrect) requests, since each one results in a significant CPU job to generate the hash (especially since I am using lots of iterations). It seems that having a "fast" algorithm is good for single use purposes, but I'm wondering if MD5 is still the best choice.
Thanks!