Skip to main content

sha256bit

CI/CD CI - Test CD - Build Documentation Status
Package PyPI - Version PyPI - Python Version
Meta Hatch project linting - Ruff code style - Black types - Mypy License - apache-2.0

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

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

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.1.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sha256bit-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sha256bit-0.1.0.tar.gz.

File metadata

  • Download URL: sha256bit-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for sha256bit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6a794c4f63b3ef5da79b1714d82b64d303131ade954e1fe903335da4fe868dde
MD5 d820254d7c4d3b57977ecd93a0d7c127
BLAKE2b-256 00ca2c7439e5c04dd3b0b0b59a403f877fe3e555b00eea1e0056a849d515b899

See more details on using hashes here.

File details

Details for the file sha256bit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sha256bit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for sha256bit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d7bbb23d6f8c0db4f2a95808d808ff375ba0cc375d999175da6c6140b07fd8
MD5 dcba7e6de25d651b043068ce798c4d59
BLAKE2b-256 f88854625a251e5383bb2487e9b5663cfbed3423b72bbeedc1e819605ee358a5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.3

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page