dict_hash
Simple python tool to hash dictionaries using both default hash and sha256. The library comes with full support for hashing Pandas DataFrame objects, Numba objects and Numpy arrays, but you will need to specify the requirements when installing the package to avoid bloating the installation process.
How do I install this package?
As usual, just download it using pip:
pip install dict_hash[all] # To install everything
pip install dict_hash[numba] # To install with numba support
pip install dict_hash[numpy] # To install with numpy support
pip install dict_hash[pandas] # To install with pandas support
Tests Coverage
Since some software handling coverages sometimes get slightly different results, here’s three of them:
Usage examples
The package offers two functions: sha256 to generate constant sha256 hashes and dict_hash, to generate hashes using the native hash function.
Session hash with dict_hash
Obtain a session hash from the given dictionary.
from dict_hash import dict_hash
from random_dict import random_dict
from random import randint
d = random_dict(randint(1, 10), randint(1, 10))
my_hash = dict_hash(d)
Consistent hash with sha256
Obtain a consistent hash from the given dictionary.
from dict_hash import sha256
from random_dict import random_dict
from random import randint
d = random_dict(randint(1, 10), randint(1, 10))
my_hash = sha256(d)
Hashable
When handling complex objects within the dictionaries, you may need to implement the class Hashable in that object.
Here is an example:
from dict_hash import Hashable, sha256
class MyHashable(Hashable):
def __init__(self, a: int):
self._a = a
self._time = time()
def consistent_hash(self) -> str:
return sha256({
"a": self._a
})
Metadata
Release files for dict-hash 1.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dict_hash-1.1.14.tar.gz | 5.2 kB | Without provenance | Details |
Release files / dict_hash-1.1.14.tar.gz
| Download URL | dict_hash-1.1.14.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
830fb99db80b40568dd91bf094a63d2305a61f9901bae80a18f636f9d08c5b6f
|
|
BLAKE2b-256 checksum How to use checksums |
bb458dc033776b156537b51bfa6dcdb345a35d39a652d29070a01370ecdb14c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Security for dict-hash 1.1.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.