simple hash library for string, file, dict, set and list
Project description
hashy
Another hash library, but with a twist. It provides a simple interface to generate hashes for strings, files, dicts, lists and sets. It also provides a decorator to cache the results of a function to disk and (optionally) memory.
Installation
pip install hashy
Introduction
hashy provides an md5, sha256 or sha512 for string, file, dict, list and set.
String and file hashes are conventional and can be compared to other implementations. For example, you can go to an online hash calculator for "a" and get the same hash as hashy generates.
Hashes for complex data types like dict, list and set are specific to hashy.
Supports multithreading and multiprocessing, via the sqlitedict library. While the sqlite database itself is not
thread-safe/process-safe, the sqlitedict library provides a thread-safe/process-safe interface.
cachy
hashy also provides cachy, a decorator that can be used to persistently cache the results of a function to
disk and (optionally) memory. It is similar to @functools.cache, except:
- Persistent (saved to local disk in a sqlite database)
- Optionally can be saved to a user-specified directory, otherwise it's the usual cache directory for the OS
- Optional user-specified cache life.
- Doesn't require arguments be frozen and/or pickle-able. Uses hashy to create a hash of the arguments.
Example
from hashy import get_string_sha256, cachy
print(get_string_sha256("a")) # prints ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb
@cachy()
def func(a):
return a + a
print(func(2)) # prints 4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hashy-0.11.0-py3-none-any.whl.
File metadata
- Download URL: hashy-0.11.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd4c4a57116e1a4340cf56ee06942919a89128f89b13573d18ba4e64d6a7b983
|
|
| MD5 |
38382dddf4f097869e6567f05cac532b
|
|
| BLAKE2b-256 |
5768ddd43c0e0a0fdc267e0504cf85f5af097368e5c938aed94f5e23323922b6
|