I've created a login system with PHP that uses md5() encryption to one-way hash the password. When the user account is created the md5 hash is stored in a field named 'password' in the MySQL table. When a user logs in the password is converted into an md5 hash and compared against the password hash in the DB table. If they match, they're let in (obviously 🙂).
The problem with this is the "one-way" nature of md5 encryption. I've used md5 in previous projects before, and it has sufficed. The problem now is that I want to be able to retrieve the password in plaintext form so that it can be e-mailed to the user as part of a 'forgotten password feature'. Obviously I don't want the password unencrypted in the DB. If I input the password in the database using something like:
INSERT INTO tableName VALUES(password($f_password));
(where $f_password is the PHP variable storing the plaintext password).
I should then be able to authenticate users and also send users their plaintext password, while storing the encrypted password in the DB table, right? Will it be secure? Is the MySQL password encryption as secure as md5?
If this won't achieve what I want, how else could I implement it?
teknodude
The problem with this is the "one-way" nature of md5 encryption. I've used md5 in previous projects before, and it has sufficed. The problem now is that I want to be able to retrieve the password in plaintext form so that it can be e-mailed to the user as part of a 'forgotten password feature'. Obviously I don't want the password unencrypted in the DB. If I input the password in the database using something like:
INSERT INTO tableName VALUES(password($f_password));
(where $f_password is the PHP variable storing the plaintext password).
I should then be able to authenticate users and also send users their plaintext password, while storing the encrypted password in the DB table, right? Will it be secure? Is the MySQL password encryption as secure as md5?
If this won't achieve what I want, how else could I implement it?
teknodude