Python md5 password value

前端 未结 4 1047
慢半拍i
慢半拍i 2020-12-19 23:47

I have this change password request form.In which the user enter their oldpasswords.

this oldpassword is the md5 format.

How to compare the md5 value from db

4条回答
  •  無奈伤痛
    2020-12-20 00:44

    the hash you put in there is a salted sha1 hexdigest as django (and probably many others) stores it by default.

    the code to verify it is in contrib/auth/models.py. From there you can see that django works with md5 by default. All you have to do is to update the old hashes to the following form:

    md5$$
    

    if your hashes aren't salted yet leave the salt empty (md5$$), but update the hash to sha1 the next time the user performs a valid login.

提交回复
热议问题