#python3.4
注意Python的版本2與3的區別
hashlib module - A common interface to many hash functions.
Hash objects have these methods:
- update(arg): Update the hash object with the bytes in arg. Repeated calls
are equivalent to a single call with the concatenation of all
the arguments.
生成hash對象后,就可以用update方法對字符串進行md5加密的更新處理
- digest(): Return the digest of the bytes passed to the update() method
so far.
得到的bytes:b'\x8f\xe2\xf6\xf8Y4\x11\xff\xb2S+\x00-\nyv'
- hexdigest(): Like digest() except the digest is returned as a unicode
object of double length, containing only hexadecimal digits.
得到的unicode 8fe2f6f8593411ffb2532b002d0a7976
hexdigest()常用
- copy(): Return a copy (clone) of the hash object. This can be used to
efficiently compute the digests of strings that share a common
initial substring.
全文:http://blog.csdn.net/chaosju/article/details/42986463 //我用 digest函數,PyCharm控制台輸出一串亂碼。之后換了,用這個 hexdigest() 就輸出真正的哈希碼,即這種形式:9d5e54f12f3f4a8b6dd02439b1a3da144ce20e89