all Python 3hashlibfunction
hashlib.sha384()
hashing
The SHA-384 hash from the SHA-2 family: 48 bytes, 96 hex digits. It is SHA-512 with different initial constants and a truncated output.
Syntax
hashlib.sha384(data=b'', *, usedforsecurity=True)
It works on 64-bit words like SHA-512, so on a 64-bit CPU without hardware SHA instructions it is often faster than sha256() on large inputs. The truncated output adds one more property: unlike sha256() and sha512(), it is not open to a length-extension attack when a hash like sha(secret + data) is misused as a signature. The right tool for a signature is still hmac.
Examples
import hashlib
h = hashlib.sha384(b'abc')
print(h.hexdigest()[:16]) # → cb00753f45a35e8b
print(h.digest_size, h.block_size) # → 48 128
See also
Open in the full glossarydocs.python.orgReport an inaccuracy