Skip to main content

Convenience hashing facilities.

Latest release 20240412:

  • BaseHashCode.hashclass(hashname): fall back to looking for blake3 from the blake3 module.
  • BaseHashCode: new get_hashfunc(hashname) static method.

Class BaseHashCode(builtins.bytes)

Base class for hashcodes, subclassed by SHA1, SHA256 et al.

You can obtain the class for a particular hasher by name, example:

SHA256 = BaseHashCode.hashclass('sha256')

Method BaseHashCode.__str__(self): Return f'{self.hashname}:{self.hex()}'.

Method BaseHashCode.from_buffer(bfr: cs.buffer.CornuCopyBuffer): Compute hashcode from the contents of the CornuCopyBuffer bfr.

Method BaseHashCode.from_data(bs): Compute hashcode from the data bs.

Method BaseHashCode.from_fspath(fspath, **kw): Compute hashcode from the contents of the file fspath.

Method BaseHashCode.from_hashbytes(hashbytes): Factory function returning a BaseHashCode object from the hash bytes.

Method BaseHashCode.from_hashbytes_hex(hashhex: str): Factory function returning a BaseHashCode object from the hash bytes hex text.

Method BaseHashCode.from_named_hashbytes_hex(hashname, hashhex): Factory function to return a HashCode object from the hash type name and the hash bytes hex text.

Method 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__.

Method BaseHashCode.get_hashfunc(hashname: str): Fetch the hash function implied by hashname.

Method BaseHashCode.hashclass(hashname: str, hashfunc=None, **kw): Return the class for the hash function named hashname.

Parameters:

  • hashname: the name of the hash function
  • hashfunc: optional hash function for the class

Property BaseHashCode.hashname: The hash code type name, derived from the class name.

Method BaseHashCode.hex(self) -> str: Return the hashcode bytes transcribes as a hexadecimal ASCII str.

Method BaseHashCode.promote(obj): Promote to a BaseHashCode instance.

Class MD5(BaseHashCode)

Hash class for the 'md5' algorithm.

MD5.hashfunc

Class SHA1(BaseHashCode)

Hash class for the 'sha1' algorithm.

SHA1.hashfunc

Class SHA224(BaseHashCode)

Hash class for the 'sha224' algorithm.

SHA224.hashfunc

Class SHA256(BaseHashCode)

Hash class for the 'sha256' algorithm.

SHA256.hashfunc

Class SHA384(BaseHashCode)

Hash class for the 'sha384' algorithm.

SHA384.hashfunc

Class SHA512(BaseHashCode)

Hash class for the 'sha512' algorithm.

SHA512.hashfunc

Release Log

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 20240412

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-hashutils 20240412
File Size Uploaded
cs.hashutils-20240412.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-hashutils 20240412
File Interpreter ABI Platform
cs.hashutils-20240412-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / cs.hashutils-20240412.tar.gz

Download URL cs.hashutils-20240412.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
56079c1f0e3eb24fa2fe3d5c16afbbef49aba8a8d11d633a69f4859f87196ec3
BLAKE2b-256 checksum
How to use checksums
5e6c73a369b4b6e50284ac5e59d088c0ce7a4288dd451f5835af60dcbc45c91a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release files / cs.hashutils-20240412-py3-none-any.whl

Download URL cs.hashutils-20240412-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9a1f959afab344b24e8cbcaea3444e620982d27fed352dc6c00ba95cc5734a4
BLAKE2b-256 checksum
How to use checksums
fa0a1219a44e94bfe553a15048f7d6198922ff01a2d2fceb80b6818ce169378c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

20240412 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page