Reading Time: 1 minutesCreating Secure Hashes/Message Digests in Python using hashlib module
Creating Secure Hashes/Message Digests in Python using hashlib module
The builtin hashlib module provides an interface to create secure hashes/message digests of algorithms such as SHA1, SHA224, SHA256, SHA384, and SHA512 & RSA’s MD5. Each of these algorithms has a corresponding class in the module, the constructors of which, along with its hexdigest() methods produces secure hashes/message digests. The input is in bytes form and output is in hexadecimal digits.
>>> hashlib.sha1(b "DjangoSpin: Articles for Pythonistas" ).hexdigest() |
'8fe8bdf0a83213d9d5ff43a5d3f3d951994e18e3' |
>>> hashlib.sha256(b "DjangoSpin: Articles for Pythonistas" ).hexdigest() |
'ea6f0fc02c4fac9f95cf0e03a18004b87c212c473eaa4bb3e1882255f0bbbdbf' |
>>> hashlib.md5(b "DjangoSpin: Articles for Pythonistas" ).hexdigest() |
'59af3c14b3f913f37e18a096bad723c2' |
See also: