|
|
|
|
|
by dendory
4732 days ago
|
|
I tend to like doing: sha256(sha256($password) . $ip) This encrypts the password and makes the cookie only usable by the IP it was set for. Then to verify the cookie, since I already store sha256 of the password, it's trivial to do, without having to store an additional token for persistence. Of course you can replace sha256 with your fav hashing function. |
|
Storing SHA-256 of passwords is a bad idea. You should use either scrypt, bcrypt, or at the very least PBDKF2 (with a large number of rounds).
For a signed token round tripped to the client you should use an HMAC[1].
[1]: http://en.m.wikipedia.org/wiki/Hash-based_message_authentica...