Skip to main content

A math-based 256-bit hashing engine written from scratch in Python.

Project description

MathHash - A Pure Math-Based 256-bit Hashing Engine

MathHash is a fully custom 256-bit hashing algorith written entirely in Python, using only mathematics, bitwise operations, and modular arithematic - no cryptographic libraries

It also inclues a simple password hashing API with random salts, making it easy for devlopers to use MathHash as a learning toop or experimental hashing engine.

⚠️ Disclaimer: MathHash is an educational hashing project. It is not a replacement for industry-standard cryptographic algorithms like Argon2, bcrypt, or SHA-256.

FEATURES

Pure Python

  • No dependencies. All math + bitwise logic written from scratch.

256 bit hash output

  • Produces a deterministic 32-bytes hash.

Salting built-in

  • Automatic random 16-bytes salts for password hashing.

Easy to integrate

-Simple API:

from mathhash import hash_password, verify_password

INSTALLATION

pip install MathHash

USAGE

Hash a password

from mathhash import hash_password

hashed = hash_password('mypassword1234')
print(hashed)

Verify a password

from mathhash import hash_password

is_valid = verify_password('mypassword1234', hashed)
print(is_valid)

HOW IT WORKS (in short)

MathHash's engine mixes:

  • modular addition
  • modular multiplication
  • left & right rotations
  • nonlinear exponentation
  • 64-bit word permutation
  • round constants inpired by Feistel & sponge desgin

PROJECT STRUCTURE

MathHash/

├── mathhash/
│ ├── __init__.py
│ ├── core.py # Password hashing & verification
│ ├── engine.py # Main 256-bit math hashing engine
│ ├── utils.py # Bit rotations & modular arithmetic
│ └── primes.py # Prime constants (optional)

├── tests/
│ └── math_hash_test.py
│ ├── README.md
├── LICENSE
└── pyproject.toml

RUNNING TESTS

Install pytest:

pip install pytest

Run test

pytest

Includes tests:

  • Random collision tests
  • Similar-input seperation
  • Avalanche effect check

⚠ SECURITY WARNING

MathHash is not cryptographically audited. Do not use it in production or to secure real user passwords.

This is for:

  • Learning
  • Research
  • Portfolio projects
  • Hackathons
  • Understanding hashing internals

CONTIBUTING

PRs and issues are welcome! Open an issue on GitHub to suggest improvements

LICENSE

This project is licensed under the MIT License. See the LICENSE file for more details.

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

mathhash-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

mathhash-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file mathhash-1.0.0.tar.gz.

File metadata

  • Download URL: mathhash-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mathhash-1.0.0.tar.gz
Algorithm Hash digest
SHA256 add903ef6075babf34917c2b96923473c85d1c71522fae43f03d39b910911478
MD5 5a75b63d7909b56de00e6f63a7b54961
BLAKE2b-256 8d54aa06ce042e4bcbb2467b5fde66a086b35f9154cbaaa375c5a456f702e759

See more details on using hashes here.

File details

Details for the file mathhash-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mathhash-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mathhash-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0889dbcd5091099de000240cec555fe19e6c73978cfc996062431d19c475ad7
MD5 e820f977ecb939e59aaffee663a13ec3
BLAKE2b-256 6bcf71db7f12266625caff20ff28c1689417399da70710ba33d08d32879c8d82

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