SHA3 with bit granularity for message input length
Project description
sha3bit
| CI/CD | |
| Package | |
| Meta |
Pure python implementation of SHA3 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
- Real
squeezfunction in addition of hashlib'sdigest - Builtin logging to see compression function IOs or even internal steps
User documentation is hosted on readthedocs.
Installation
python3 -m pip install sha3bit
Usage
One liner
>>> from sha3bit import sha3_256
>>> print(sha3_256("abc".encode()).hexdigest())
'3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532'
Bit length capability
>>> from sha3bit import sha3_256
>>> print(sha3_256(b'\x00',bitlen=1).hexdigest())
'1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2'
Import/export
>>> from sha3bit import sha3_256
>>> h1 = sha3_256("a".encode())
>>> state = h1.export_state()
>>> h2 = sha3_256.import_state(state)
>>> h2.update("bc".encode())
>>> print(h2.hexdigest())
'3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532'
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_api_xof_absorb
python3 -m test.test_cavp
python3 -m test.test_cavp_xof
python3 -m test.test_hardcoded
python3 -m test.test_sha3_vs_hashlib
python3 -m test.test_shake_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.9
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sha3bit-0.3.0.tar.gz.
File metadata
- Download URL: sha3bit-0.3.0.tar.gz
- Upload date:
- Size: 6.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7c4882af5471e1b481608e77ad9642578c560f4f72f576b9a2679d5b7b5431e
|
|
| MD5 |
972215e2d5d614e49fe8d62ee2da2430
|
|
| BLAKE2b-256 |
ba12b48e26e320931b7d999fbae22b4f57dcffb2172d9e246493edee7b002f83
|
File details
Details for the file sha3bit-0.3.0-py3-none-any.whl.
File metadata
- Download URL: sha3bit-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ff073a40e794a88b44eec386eae21646ba925d683538b2d326ae0a007aec2df
|
|
| MD5 |
c8455263d4bcc3a4559db6f27c3b98eb
|
|
| BLAKE2b-256 |
7794e6246e567d88b000e9169b9b1da1bbbca1884c16e811fdf7da2ecf7ec76b
|