[Solved] Python hashlib MD5 Error: TypeError: Unicode-objects must be encoded before hashing

1.error message: TypeError: Unicode-objects must be encoded before hashing

2.error message: TypeError: object supporting the buffer API required

The correct way to write it should be

codes:

import hashlib
def md5pwd(password):
m = hashlib.md5()
m.update(password)
mpwd = m.hexdigest()
return mpwd
print(md5pwd(b’123456′))

 

Similar Posts: