hashlib

The Python standard-library module that computes stable cryptographic hashes such as SHA-256.

In more detail

Unlike the built-in hash(), hashlib digests are the same on every run and every machine, so they suit identifiers stored in files or sent between processes. You pass bytes, not str, so text is encoded first. It offers SHA-256 and several other standard hash algorithms.

Examples

hashlib.sha256('apple'.encode()).hexdigest()[:16]
The course derives a Bloom filter's k positions from SHA-256 by hashing the item with k different prefixes.

Related terms

Taught in

References