MtHasher
Calculate multiple hash digests for a piece of data in parallel, one algo/thread.
Based on the code of Peter Wu peter@lekensteyn.nl (https://git.lekensteyn.nl/scripts/tree/digest.py).
Usage
From CLI
Add data over STDIN and/or as arguments and select the desired algorithms:
cat data.txt | python3 -m mthasher -i data2.txt - --sha1 --sha256 -o checksums.txt
At least one algorithm is mandatory and by default the script reads from STDIN and writes to STDOUT.
From Python
The exposed API is the following
ALGORITHMS_GUARANTEED: The tuple of the supported algorithmsHasher(): Single-threaded hasher, takes an iterable (e.g. list of algorithms to use)MtHasher()Multi-threaded hasher, takes an iterable (e.g. list of algorithms to use)
Both hashers expose the following API
header: tuple of header elements ("filename" and the list of algorithms in the supplied order)algos: tuple of supplied algorithmshash_file(): Takes a filename or a file-like object on bytes, returns the digest tuple in same order as header (the filename is omited)hash_multiple_files():Takes an iterable of filenames or file-like objects on bytes,returns the generator of filename + digest tuples in same order as header, one for every input object
Example
from io import BytesIO
from mthasher import MtHasher
hasher = MtHasher(('sha1', 'md5'))
filename_header, sha1_header, md5_header = hasher.header
sha1_digest, md5_digest = hasher.hash_file('data.txt')
for filename, sha1_digest, md5_digest in hasher.hash_multiple_files(('data.txt', open('data2.txt', 'rb'), '-', BytesIO('bytesstring'))):
# First the header and then the digests
print(filename, sha1_digest, md5_digest, sep='\t')
Supported algorithms
- md5
- sha1
- sha224
- sha256
- sha384
- sha512
- sha3_224
- sha3_256
- sha3_384
- sha3_512
- blake2b
- blake2s
License
Licensed under the MIT license http://opensource.org/licenses/MIT
Metadata
Release files for mthasher 2.0.4
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 | Actions |
|---|---|---|---|---|
| mthasher-2.0.4.tar.gz | 5.3 kB | Without provenance | Details for mthasher-2.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mthasher-2.0.4-py3-none-any.whl | Python 3 | none | any | Details for mthasher-2.0.4-py3-none-any.whl |
Total release size: 11.7 kB
Release files / mthasher-2.0.4.tar.gz
| Download URL | mthasher-2.0.4.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ec05afca15e12ccca73238caf44e7aa52d2cae8a2547efe9b3657d0980ada64
|
|
BLAKE2b-256 checksum How to use checksums |
7e942ab9c10b2260e8199cf8d9d1051ac14dc81bb22d8713b79ae26c4d6838c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.8.3 Linux/5.11.0-1028-gcp
|
Release files / mthasher-2.0.4-py3-none-any.whl
| Download URL | mthasher-2.0.4-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c37d16755a7f01b45bb08c87bb6f8843235e82ea9611c2abbca0c17de04c693
|
|
BLAKE2b-256 checksum How to use checksums |
2d862503c9ab5f572faa175541fb153261debc240101401fc1250186b3e9ba4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.8.3 Linux/5.11.0-1028-gcp
|
Security for mthasher 2.0.4
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.