Skip to main content

Premium SHA-67 Hashing Cryptographic Module in Rust

Project description

SHA-67: Cryptographic Modulo Hash Library

PyPI Version License Rust

A premium, high-performance cryptographic hashing library written in Rust and packaged as a native Python extension.

Instead of standard binary-based hashing algorithms (like SHA-256 with $2^{256}$ keyspace), SHA-67 hashes inputs into a base-67 number system represented by exactly 67 digits, providing a keyspace of $67^{67}$ possible values.


📐 Mathematical Foundations

Why $67^{67}$?

In traditional computer science, data is structured in powers of two. However, by using a 67-symbol alphabet and generating hashes that are exactly 67 characters long, we unlock a keyspace of: $$\text{Keyspace Size} = 67^{67} \approx 1.54 \times 10^{122}$$

This is equivalent to a $\approx 406.4$-bit cryptographic keyspace (since $\log_2(67^{67}) = 67 \log_2(67) \approx 406.42$ bits of entropy). This space is astronomically large, making brute-force attacks mathematically impossible.

Base-67 Alphabet

SHA-67 utilizes a curated alphabet of 67 printable, unreserved, and highly readable ASCII characters:

0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~!
  • 0-9 (10 symbols)
  • a-z (26 symbols)
  • A-Z (26 symbols)
  • -, _, ., ~ (4 RFC-3986 unreserved symbols)
  • ! (1 safe exclamation symbol)

The Algorithm

Inputs are hashed using SHA-512 (producing 512 bits of high-quality entropy). This 512-bit value is interpreted as a large unsigned integer, reduced modulo $67^{67}$, and mapped onto our 67-character base-67 alphabet. Because SHA-512's output space ($2^{512}$) is much larger than $67^{67}$, the modulo reduction introduces practically zero modulo bias ($< 1$ part in $2^{105}$), ensuring cryptographic integrity.


📥 Installation

Install the package directly from PyPI:

pip install sha67

Note: For macOS Apple Silicon users, precompiled binary wheels are available for instant installation. On other systems, pip will compile the Rust extension in the background automatically (requires the Rust toolchain installed).


🐍 Python Usage

The Python module is designed to accept both standard strings (str) and byte sequences (bytes / bytearray).

1. Simple Single-Pass Hashing

Compute a 67-character hash instantly:

import sha67

# Hashing a string
hash_str = sha67.sha67("Hello, World!")
print(hash_str)
# Output: 1XHwYd8ki-_mtxzjb1HbXtT4V!xaxDwNqN7CFk!4zOtxqICIJ6o1Q16YztNWyl_AACF

# Hashing bytes
hash_from_bytes = sha67.sha67(b"Hello, World!")

2. Large Integer & Byte Digests

You can retrieve the underlying reduced big integer or raw bytes:

# Get the hash as a large Python integer (modulo 67^67)
hash_int = sha67.sha67_int("Hello, World!")
print(hash_int)
# Output: 6272842035196...

# Get the hash as a 51-byte representation
hash_bytes = sha67.sha67_bytes("Hello, World!")
print(hash_bytes.hex())

3. Hashlib-style Incremental Hashing

SHA-67 provides an incremental hasher class that mimics Python's standard hashlib interface:

hasher = sha67.SHA67()
hasher.update("Hello, ")
hasher.update("World!")

# Obtain digests in multiple formats
print("Base67 Digest: ", hasher.base67digest())
print("Hex Digest:    ", hasher.hexdigest())
print("Int Digest:    ", hasher.intdigest())
print("Raw Bytes:     ", hasher.digest())

4. Custom Key Derivation (PBKDF-SHA67)

Strengthen password keys against offline dictionary attacks using iterative hashing with salt stretching:

password = "supersecretpassword"
salt = "random_salt_123"
iterations = 10000

derived_key = sha67.pbkdf_sha67(password, salt, iterations)
print("Derived Key: ", derived_key)
# Output: zNHbKgeEnRP~2frOpVbceCUfTsQ_Sr3pY1YJM9CMi!tT0Qjn.oZYDrO_nYWRl0OxAlP

🦀 Standalone Rust CLI Usage

The package also compiles into a standalone, high-performance UNIX command-line utility.

Compile the CLI:

cargo build --release

Hashing inputs via CLI:

# Hash a string directly
./target/release/sha67 -s "Hello, World!"

# Hash a file
./target/release/sha67 Cargo.toml

# Stream and hash from standard input
echo -n "cryptography" | ./target/release/sha67

📄 License

This project is licensed under the MIT License.

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

sha67-0.1.1.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

sha67-0.1.1-cp37-abi3-macosx_11_0_arm64.whl (244.3 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

Details for the file sha67-0.1.1.tar.gz.

File metadata

  • Download URL: sha67-0.1.1.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for sha67-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c7c2fdccb7842d52eb8fa6725575ada62499431f243721e37cf5d0fa94c06b65
MD5 8d180e6aae0d30ef7a6d74338ee72ebb
BLAKE2b-256 8361ae9ab31694779cae4c2a74644655acb3c75e963838c16d534e2ee132be64

See more details on using hashes here.

File details

Details for the file sha67-0.1.1-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sha67-0.1.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 15875e68a35732dc9eff5f5b0201bfb6ef010958d825166c068cd7ea7be17c86
MD5 e7069e3f7121238e0167442472cc2af1
BLAKE2b-256 8fe3132a15cf1312afde8838335318fd1da799f7654e7349284977d0e0c85689

See more details on using hashes here.

Supported by

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