provides a python module for encrypted hash: hashlib
One of the following major record md5 encryption
>>> Import hashlib
>>> M = hashlib.md5 ()
>>> M.update ("Nobody inspects")
>>> M.update ("the spammish repetition")
>>> M.digest ()
'\ Xbbd \ x9c \ x83 \ xdd \ x1e \ xa5 \ xc9 \ xd9 \ xde \ xc9 \ xa1 \ x8d \ xf0 \ xff \ xe9'
>>> M.hexdigest ()
A description of the code above:
1. First, from the python module directly into hashlib
2. Call hashlib in the md5 () generates a md5 hash object
3. Generate hash object, you can update method md5 encrypted string update processing
4. To call the update method on the basis of the previous update the encrypted encryption
5. Encrypted binary result
6. Hexadecimal Results
If you only need to encrypt a string, a statement can also be used by:
>>> Print hashlib.new ("md5", "Nobody inspects the spammish repetition"). Hexdigest ()
Part of the official documents refer to:
The following values are provided as constant attributes of the hash objects returned by the constructors:
The size of the resulting hash in bytes.
The internal block size of the hash algorithm in bytes.
A hash object has the following methods:
hash.update (arg) ¶
Update the hash object with the string arg. Repeated calls are equivalent to a single call with the concatenation of all the arguments: m.update (a); m.update (b) is equivalent to m.update (a + b).
hash.digest () ¶
Return the digest of the strings passed to the update () method so far. This is a string of digest_size bytes which may contain non-ASCII characters, including null bytes.
hash.hexdigest () ¶
Like digest () except the digest is returned as a string of double length, containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments.
hash.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.