Import Hashlib
user = ' Jointwisdom '
PWD = ' zhonghui123 '
m2 = hashlib.md5 ()
M2.update (Pwd.encode ("Utf-8")) #参数必须是byte类型, otherwise reported unicode-objects must be encoded before hashing error
Print (M2.hexdigest ())
# But what about the Chinese string MD5?
# Chinese characters in Python are in Unicode, the same string in different coding system has different values, so before the hash to encode, personal advice to gb2312, because the contrast found that The MD5 value calculated by one of the tools I downloaded is the same as the MD5 value calculated after the gb2312 code. (! Online MD5 a lot of tools, is not all the MD5 tools are such, not to research, interested can study it
# [Python] view plain copy print?
# import Hashlib
# data= ' I am '
# m = hashlib.md5 (Data.encode (encoding= ' gb2312 '))
# Print (M.hexdigest ())
Python3 MD5 Encryption