SHA256 with bit granularity for message input length
Project description
sha256bit
CI/CD | |
Package | |
Meta |
Pure python implementation of SHA256 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'
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
Build the package
Build is done using hatchling
. The script build
allows to build for different version of python3:
./build python3.9
Create a new version
Version is managed by hatch-vcs
, you just need to create a tag in github.
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 Distribution
sha256bit-0.0.10.tar.gz
(2.0 MB
view hashes)
Built Distribution
Close
Hashes for sha256bit-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a34e1e7be63402eab0a1c1878831479a9fd1f4313e04b78af87283f98a6f1ad3 |
|
MD5 | aecf0b417f2942012377a4db93b3f6b7 |
|
BLAKE2b-256 | cbbad6a5505e8815b975a8a77eaa2e8a5c0d9a4dc8a2a847464492cfe2147b4a |