Python Glossary Русский

Python 3.6+hashlibfunction

hashlib.sha3_224()

hashing

The SHA3-224 hash (SHA-3 family, Keccak): 28 bytes, 56 hex digits. Same length as SHA-224, but a different algorithm.

Syntax

hashlib.sha3_224(data=b'', *, usedforsecurity=True)

SHA-3 is built differently from SHA-2 (a sponge instead of the Merkle-Damgard construction), so sha3_224() and sha224() 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 short variant: pick it when a format explicitly demands SHA3-224.

Examples

import hashlib
h = hashlib.sha3_224(b'abc')
print(h.hexdigest()[:16])  # → e642824c3f8cf24a
print(h.digest_size, h.block_size)  # → 28 144
import hashlib
a = hashlib.sha3_224(b'abc').hexdigest()
b = hashlib.sha224(b'abc').hexdigest()
print(len(a) == len(b), a == b)  # → True False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy