sha256bit
| CI/CD | |
| Package | |
| Meta |
Pure python implementation of SHA256 and SHA224 with features which are often lacking:
- bit granularity for message input length
- import/export API to "persist" the state in the middle of a hash computation
User documentation is hosted on readthedocs.
Installation
python3 -m pip install sha256bit
Usage
One liner
>>> from sha256bit import Sha256bit
>>> Sha256bit("abc".encode()).hexdigest()
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
SHA-224
Sha224bit has the same API as Sha256bit.
>>> from sha256bit import Sha224bit
>>> Sha224bit("abc".encode()).hexdigest()
'23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7'
Bit length capability
>>> from sha256bit import Sha256bit
>>> Sha256bit(b'\x00',bitlen=1).hexdigest()
'bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375'
Import/export
>>> from sha256bit import Sha256bit
>>> h1 = Sha256bit("a".encode())
>>> state = h1.export_state()
>>> h2 = Sha256bit.import_state(state)
>>> h2.update("bc".encode())
>>> h2.hexdigest()
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
Test with pytest
pytest-3
Test without pytest
Tests can run without creating/installing the package:
python3 -m test.test
you can also run each test separately:
python3 -m test.test_api
python3 -m test.test_cavp
python3 -m test.test_hardcoded
python3 -m test.test_vs_hashlib
Generate the doc
cd docs
pipenv shell
make clean doctest html
Update pipenv for the doc
cd docs
pipenv shell
#use pip to update whatever ou want
pip freeze > requirements.txt
pipenv update
Build the package
Build is done using hatchling. The script build allows to build for different version of python3:
./build python3.12
Create a new version
Version is managed by hatch-vcs, you just need to create a tag in github.
Launch linters
They use the configuration from pyproject.toml
./lint
Metadata
Release files for sha256bit 0.2.3
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 |
|---|---|---|---|---|
| sha256bit-0.2.3.tar.gz | 3.9 MB | With provenance | Details for sha256bit-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sha256bit-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for sha256bit-0.2.3-py3-none-any.whl |
Total release size: 4.0 MB
Release files / sha256bit-0.2.3.tar.gz
| Download URL | sha256bit-0.2.3.tar.gz |
|---|---|
| Size | 3.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9382897d8253b2d3646a5a11c504273c39d24b6adabceae8469c124f5c8fd3b4
|
|
BLAKE2b-256 checksum How to use checksums |
9656e11dca8e06b66eb5060d753c8a62d0164aa06e07d86ca8055f3715262295
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / sha256bit-0.2.3-py3-none-any.whl
| Download URL | sha256bit-0.2.3-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bb364edf3d31befd86cfcc8b210aa5e26d1628d99ce1e9a2e165fb629a68380
|
|
BLAKE2b-256 checksum How to use checksums |
7c220e0dd1f6aabd83cf8b29aabd28367545b943e9063a64f9c533d1b898a7f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logSecurity for sha256bit 0.2.3
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sha256bit-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logA 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.