Search code examples
pythonwerkzeug

How to convert md5 32 bytes hash to corresponding sha256 in python


I have a database that contains md5 hashs, i want to convert them to another type of hash so that the users can login to the new website.

I am using the werkzeug.security library to generate the hashs.

I there is any way to do that ??


Solution

  • MD5 is a one-way hash function, there is no way to reverse it so it can be re-endoded as another type of hash.

    The usual approach to this problem is to intercept the login process, obtain the plain text password and encode it separately for the new system. Make sure that you are using a modern password hashing algorithm like bcrypt or scrypt instead of SHA256.