
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
The stablehash module provides a "pure" hash function that is stable across Python processes and runs. This is in
contrast to the builtin hash() function, which may return a different value for the same input in separate
invokations even with the Python version.
We support most Python built-in types, including mutable types such as list and dict, as well as dataclasses. The
default internal hash algorithm is Blake2b, but this can be changed by passing a different hashlib algorithm to the
stablehash function.
from stablehash import stablehash
assert stablehash({"key": "value"}, algorithm="md5").hexdigest() == 'd5994850379366e314563ea555532052'
stablehash(obj=..., *, algorithm="blake2b")Returns a hashlib-compatible object with the given algorithm and the hash of the given object. The algorithm must be
one of the algorithms supported by hashlib.
stablehash.update(obj)Updates the hash with the given object. If the object is not supported, a TypeError is raised.
stablehash.digest()Returns the digest of the hash as a bytes object.
stablehash.hexdigest()Returns the digest of the hash as a string object.
The following types are supported:
Noneboolintfloatstrbytestuplelistsetfrozensetdict@dataclass objectsdatetime objects (datetime, date, time and timedelta)uuid.UUID__getstate__())type objects (by their full qualified name)FAQs
Stable hashing of Python data structures across separate processes and platforms.
We found that stablehash demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.