Skip to main content

No project description provided

Project description

test codecov

hoshrust (see hosh for the implementation of the current specification)

Fast cryptographic 22-digit hash and operators for Rust and Python. This is based on the Symmetric group, which is not robust to many repetitions (see hosh for a robust 40-digit version).

Colored base-62 representation

Python installation

from package

# Set up a virtualenv. 
python3 -m venv venv
source venv/bin/activate

# Install from PyPI
pip install hoshrust

from source

cd my-project
git clone https://github.com/davips/hoshrust ../hoshrust
pip install -e ../hoshrust

Examples

Basic operations

from hoshrust import Hash

# Hashes can be multiplied.
a = Hash(blob=b"Some large binary content...")
b = Hash(blob=b"Some other binary content. Might be, e.g., an action or another large content.")
c = a * b
print(f"{a} * {b} = {c}")
"""
0v58YxIhaae5NfYuXsoC1i * 04orKjYHAZraYORILOVwos = 3yT1A5oLlW2HpjSkgzo2yg
"""
# Multiplication can be reverted by the inverse hash. Zero is the identity hash.
print(f"{b} * {~b} = {b * ~b} = 0")
"""
04orKjYHAZraYORILOVwos * 211eErwhEiGnit0beo4tjo = 0000000000000000000000 = 0
"""
print(f"{c} * {~b} = {c * ~b} = {a} = a")
"""
3yT1A5oLlW2HpjSkgzo2yg * 211eErwhEiGnit0beo4tjo = 0v58YxIhaae5NfYuXsoC1i = 0v58YxIhaae5NfYuXsoC1i = a
"""
print(f"{~a} * {c} = {~a * c} = {b} = b")
"""
4q4X1jczNK2eKCV4uxEPNk * 3yT1A5oLlW2HpjSkgzo2yg = 04orKjYHAZraYORILOVwos = 04orKjYHAZraYORILOVwos = b
"""
# Division is shorthand for reversion.
print(f"{c} / {b} = {c / b} = a")
"""
3yT1A5oLlW2HpjSkgzo2yg / 04orKjYHAZraYORILOVwos = 0v58YxIhaae5NfYuXsoC1i = a
"""
# Hash multiplication is not expected to be commutative.
print(f"{a * b} != {b * a}")
"""
3yT1A5oLlW2HpjSkgzo2yg != 4AvOF9Fbhakd26mosfuuvR
"""
# Hash multiplication is associative.
print(f"{a * (b * c)} = {(a * b) * c}")
"""
51UdYbEAGI5mVogE4aFFKe = 51UdYbEAGI5mVogE4aFFKe
"""

Features

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hoshrust-0.211225.0.tar.gz (6.1 MB view hashes)

Uploaded Source

Built Distributions

hoshrust-0.211225.0-cp39-cp39-manylinux2010_x86_64.whl (559.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

hoshrust-0.211225.0-cp39-cp39-manylinux1_x86_64.whl (559.5 kB view hashes)

Uploaded CPython 3.9

hoshrust-0.211225.0-cp38-cp38-manylinux2010_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

hoshrust-0.211225.0-cp38-cp38-manylinux1_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.8

hoshrust-0.211225.0-cp37-cp37m-manylinux2010_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

hoshrust-0.211225.0-cp37-cp37m-manylinux1_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.7m

hoshrust-0.211225.0-cp36-cp36m-manylinux2010_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

hoshrust-0.211225.0-cp36-cp36m-manylinux1_x86_64.whl (559.6 kB view hashes)

Uploaded CPython 3.6m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page