1.报错信息是:TypeError: Unicode-objects must be encoded before hashing
2.报错信息是:TypeError: object supporting the buffer API required
正确的写法应该是
代码:
import hashlib
def md5pwd(password):
m = hashlib.md5()
m.update(password)
mpwd = m.hexdigest()
return mpwd
print(md5pwd(b'123456'))