MYSQL PASSWORD()到MD5()Wordpress [关闭]

I have and old table for users.

Old insert example: INSERT INTO user SET password = PASSWORD('qwerty')

I need to import all users from the old table to WordPress users. How can I do it?

MySQL's PASSWORD() function does a double-SHA1 hashing, which is not reversible. You cannot retrieve the original password.

To convert to a different hash function, you must ask your users to re-enter their password.


Further thought: I had an experience once to change the hash function for an application. I could not ask all the users to re-enter their password. So I had to write special code in the application to support both hash formats. When validating passwords on login, fetch the hashed password, infer the hashing function from the length of the hash string, and then perform the password validation in the application. When any user changed their password, of course store the hash using the new function. Eventually almost all users had unknowingly converted their password storage to the new function. Then I contacted just a few users to ask them to change their password.

This strategy works unless you have a required deadline for upgrading all password hashing, for example to comply with some security regulation. I had the advantage that the application was only an intranet application and there was no strict deadline.