I'm currently developing a user login system, and the passwords are stored one-way encrypted of course.
I started off using the mysql PASSWORD() function, but if 2 users have the same password, the encrypted version would be the same as well, which I'm not quite happy with.
So I consider using php's crypt() now, which should work fine this way:
// on insert and update
crypt($pwd); // always different with same $pwd
// to compare
if ($from_db == crypt($pwd, substr($from_db,0,CRYPT_SALT_LENGTH)))
However, what I'm really worried about: CRYPT_SALT_LENGTH is dependent on the system if I understand it correctly. Now, if the system would be updated, no user that registered before that time would be able to login anymore, or am I wrong?
The safest way I can think of right now would be to store the CRYPT_SALT_LENGTH along with each password. Any other suggestions? How do you handle this?
[edit: the example was a bit off, should be better now]
edit:
I've just had another idea: what about leaving the password PASSWORD() encrypted in the DB as it is, but encrypt this one again with crypt() when I need to store it client side? (the login uses either cookies or single login -again and again *g- for each protected action. I do have reasons not to use sessions.)