Function: can be used to encrypt. MD5, SHA1, SHA256, sha512
1>>>Importhashlib #导入hashlib加密模块2>>> m=hashlib.md5 () #定义一个md5对象3>>>Print(m)4<md5 Hash Object @ 0x7fb78f99c6c0> #输出对象m可以看出是一个md5 Hash5>>> M.update ("Hello World". Encode ('UTF8') #对hello World for MD5 encryption, character encoding using UTF8 format, and character encoding in Python3 by default in Unicode format. 6>>>7>>>Printm8<md5 HASH Object @ 0x7fb78f99c6c0>9>>>Printm.hexdigest () #以十六进制方式输出m, you will find that the characters inside are not more than F (Hex range). Ten5eb63bbbe01eeed093cb22bb8f5acdc3
>>> m.update (' Qiyuanchang '. Encode (' UTF8 ')) #这里的update是在上一次hello wold based on the underlying encryption, not a new encryption at a time.
>>> Print m.hexdigest ()
8e307de43044db33276a97776259562b
->>> m2=hashlib.md5 () #这里重新创建一个hash加密对象m2, the cryptographic characters are the same as the two operations above, and the results are the same after the encryption is found.
>>> m2.update ("Hello Worldqiyuanchang". Encode (' UTF8 '))
>>> print m2.hexdigest ()
8e307de43044db33276a97776259562b
Python hashlib module