Convenience hashing facilities.
Latest release 20250414: Define BLAKE3 if we can import blake3.
Module contents:
-
ClassBaseHashCode(builtins.bytes): Base class for hashcodes, subclassed bySHA1,SHA256` et al.You can obtain the class for a particular hasher by name, example:
SHA256 = BaseHashCode.hashclass('sha256')
BaseHashCode.__str__(self):
Return f'{self.hashname}:{self.hex()}'.
BaseHashCode.from_buffer(bfr: cs.buffer.CornuCopyBuffer):
Compute hashcode from the contents of the CornuCopyBuffer bfr.
BaseHashCode.from_data(bs):
Compute hashcode from the data bs.
BaseHashCode.from_fspath(fspath, **kw):
Compute hashcode from the contents of the file fspath.
BaseHashCode.from_hashbytes(hashbytes):
Factory function returning a BaseHashCode object from the hash bytes.
BaseHashCode.from_hashbytes_hex(hashhex: str):
Factory function returning a BaseHashCode object
from the hash bytes hex text.
BaseHashCode.from_named_hashbytes_hex(hashname, hashhex):
Factory function to return a BaseHashCode object
from the hash type name and the hash bytes hex text.
BaseHashCode.from_prefixed_hashbytes_hex(hashtext: str):
Factory function returning a BaseHashCode object
from the hash bytes hex text prefixed by the hashname.
This is the reverse of __str__.
BaseHashCode.get_hashfunc(hashname: str):
Fetch the hash function implied by hashname.
BaseHashCode.hashclass(hashname: str, hashfunc=None, **kw):
Return the class for the hash function named hashname.
Parameters:
hashname: the name of the hash functionhashfunc: optional hash function for the class
BaseHashCode.hashname:
The hash code type name, derived from the class name.
BaseHashCode.hex(self) -> str:
Return the hashcode bytes transcribes as a hexadecimal ASCII str.
BaseHashCode.promote(obj):
Promote to a BaseHashCode instance.
BLAKE3.hashfunc
MD5.hashfunc
SHA1.hashfunc
SHA224.hashfunc
SHA256.hashfunc
SHA384.hashfunc
SHA512.hashfunc
Release Log
Release 20250414: Define BLAKE3 if we can import blake3.
Release 20241207: BaseHashCode.hashclass: raise ValueError from unknown hash function name with greater detail on the underlying failure.
Release 20240412:
- BaseHashCode.hashclass(hashname): fall back to looking for blake3 from the blake3 module.
- BaseHashCode: new get_hashfunc(hashname) static method.
Release 20240316: Fixed release upload artifacts.
Release 20240211: Initial PyPI release: BaseHashCode(bytes) and subclasses for various hash algorithms.
Release files for cs-hashutils 20250414
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs_hashutils-20250414.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs_hashutils-20250414-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 8.8 kB
Release files / cs_hashutils-20250414.tar.gz
| Download URL | cs_hashutils-20250414.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02ba3b0de67d78275270f8b481ced14baf54dc14e6b86a223a34516bdb4fbdf5
|
|
BLAKE2b-256 checksum How to use checksums |
443906bcd6916efcd8f63386258a00e351f35963871fa551a9a69289f0321b45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / cs_hashutils-20250414-py2.py3-none-any.whl
| Download URL | cs_hashutils-20250414-py2.py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6bfa9e8e153c7faf0f6da936c0fbe8da1c54828a2fb9e127126c1cd0144665cb
|
|
BLAKE2b-256 checksum How to use checksums |
bfad3aaebe6786266f1cbe0067ebc0186438865fa6cdc72bd65353adacd80d14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|