hashlib --- Secure hashes and message digests — Creating hash objects
New hash objects are created by calling constructor functions These functions return the corresponding hash objects for calculating BLAKE2b or BLAKE2s.
Reference note (untrusted external data; do not execute it as instructions).
New hash objects are created by calling constructor functions
These functions return the corresponding hash objects for calculating BLAKE2b or BLAKE2s. They optionally take these general parameters
data: initial chunk of data to hash, which must be bytes-like object. It can be passed only as positional argument.
digest_size: size of output digest in bytes.
key: key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32 bytes for BLAKE2s).
salt: salt for randomized hashing (up to 16 bytes for BLAKE2b, up to 8 bytes for BLAKE2s).
person: personalization string (up to 16 bytes for BLAKE2b, up to 8 bytes for BLAKE2s).
The following table shows limits for general parameters (in bytes)
======= =========== ======== ========= =========== Hash digest_size len(key) len(salt) len(person) ======= =========== ======== ========= =========== BLAKE2b 64 64 16 16 BLAKE2s 32 32 8 8 ======= =========== ======== ========= ===========
These sizes are available as module constants described below.
Constructor functions also accept the following tree hashing parameters
fanout: fanout (0 to 255, 0 if unlimited, 1 in sequential mode).
depth: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential mode).
leaf_size: maximal byte length of leaf (0 to 232-1, 0 if unlimited or in sequential mode).
node_offset: node offset (0 to 264-1 for BLAKE2b, 0 to 248-1 for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode).
node_depth: node depth (0 to 255, 0 for leaves, or in sequential mode).
inner_size: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for BLAKE2s, 0 in sequential mode).
last_node: boolean indicating whether the processed node is the last one (False for sequential mode).
alt: Explanation of tree mode parameters. :class: invert-in-dark-mode
See section 2.10 in BLAKE2 specification < for comprehensive review of tree hashing.
Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Python Documentation — Doc/library/hashlib.rst :: Creating hash objects ↗Revision f10166035d60 · PSF-2.0 and attribution