Contents

hashlib - Secure hashes and message digests

Contents

hashlib - Secure hashes and message digests

hashlib provides a

>>> import hashlib

>>> hashlib.algorithms_available
{'sha3_384', 'sha1', 'sha256', 'sha512', 'mdc2', 'sha512_256', 'sha224', 'sm3',
'shake_256', 'whirlpool', 'sha384', 'blake2b', 'sha512_224', 'md5', 'sha3_256',
'ripemd160', 'sha3_512', 'shake_128', 'blake2s', 'md5-sha1', 'sha3_224', 'md4'}
>>> hashlib.algorithms_guaranteed
{'sha3_384', 'blake2b', 'sha1', 'sha224', 'sha3_512', 'md5', 'shake_128', 'sha3_256',
'sha256', 'blake2s', 'shake_256', 'sha512', 'sha384', 'sha3_224'}
import hashlib
m = hashlib.sha256()
m.update(b"Hello World!")
m.digest()
# output
b'\x7f\x83\xb1e\x7f\xf1\xfcS\xb9-\xc1\x81H\xa1\xd6]\xfc-K\x1f\xa3\xd6w(J\xdd\xd2\x00\x12m\x90i'