Python 3.6+hashlibfunction
hashlib.sha3_512()
hashing
The SHA3-512 hash (SHA-3 family, Keccak): 64 bytes, 128 hex digits. Same length as SHA-512, but a different algorithm.
Syntax
hashlib.sha3_512(data=b'', *, usedforsecurity=True)
SHA-3 is built differently from SHA-2 (a sponge instead of the Merkle-Damgard construction), so sha3_512() and sha512() give different values, and SHA-3 has no length-extension attack. A trap when matching other systems: Ethereum and some libraries call the original Keccak "keccak256", which is not the standardized SHA3-256 — the hashes will not match. The longest and slowest of the four: its block is only 72 bytes.
Examples
import hashlib
h = hashlib.sha3_512(b'abc')
print(h.hexdigest()[:16]) # → b751850b1a57168a
print(h.digest_size, h.block_size) # → 64 72
import hashlib
a = hashlib.sha3_512(b'abc').hexdigest()
b = hashlib.sha512(b'abc').hexdigest()
print(len(a) == len(b), a == b) # → True False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy