On this page
hashlib.blake2b
Up: hashlib | Next: hashlib.blake2s
Rel: hashlib.blake2s, hashlib.file_digest, hashlib.md5, hashlib.new
Ref: docs.python.org — hashlib.blake2b
Tags: #public #python3 #stdlib #hashlib
Import
import hashlib
from hashlib import blake2b
Signature & Overview
hashlib.blake2b(data=b'', *, digest_size=64, key=b'', salt=b'', person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True, string=None)
Return a new BLAKE2b hash object.
Methods & Attributes
blake2b.copy(self, /)— Return a copy of the hash object.blake2b.digest(self, /)— Return the digest value as a bytes object.blake2b.hexdigest(self, /)— Return the digest value as a string of hexadecimal digits.blake2b.update(self, data, /)— Update this hash object's state with the provided bytes-like object.
Usage
import hashlib
digest = hashlib.blake2b(b"hello", digest_size=16).hexdigest()
assert len(digest) == 32
Gotchas
- Fast, modern 64-bit cryptographic hash: Faster than SHA-256 on 64-bit CPUs and supports built-in keyed hashing (
key=) and variabledigest_size(1..64 bytes). - Accepts
bytesonly: Encodestrwith.encode("utf-8")first.
REPL Inspect
from hashlib import blake2b
help(blake2b)
Linked from
- tuts/python3/stdlib_module/hashlib
- tuts/python3/stdlib_module/hashlib/blake2s
- tuts/python3/stdlib_module/hashlib/file_digest
- tuts/python3/stdlib_module/hashlib/md5
- tuts/python3/stdlib_module/hashlib/new
- tuts/python3/stdlib_module/hashlib/pbkdf2_hmac
- tuts/python3/stdlib_module/hashlib/sha1
- tuts/python3/stdlib_module/hashlib/sha224
- tuts/python3/stdlib_module/hashlib/sha256
- tuts/python3/stdlib_module/hashlib/sha384
- tuts/python3/stdlib_module/hashlib/sha3_224
- tuts/python3/stdlib_module/hashlib/sha3_256
- tuts/python3/stdlib_module/hashlib/sha3_384
- tuts/python3/stdlib_module/hashlib/sha3_512
- tuts/python3/stdlib_module/hashlib/sha512
- tuts/python3/stdlib_module/hashlib/shake_128
- tuts/python3/stdlib_module/hashlib/shake_256
Related notes
- tuts/python3/stdlib_module/hashlib/blake2s Linked here; links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/file_digest Linked here; links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/md5 Linked here; links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/new Linked here; links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/hashlib/pbkdf2_hmac links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/sha1 links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/sha224 links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/sha256 links to this page; shared tags: #hashlib, #stdlib
- tuts/python3/stdlib_module/hashlib/sha384 links to this page; shared tags: #hashlib, #stdlib