Skip to main content

Custom password hashing and file encryption — C++ core, Python bindings

Project description

enigma-encryption

Custom password hashing and file encryption — a C++ monorepo that builds:

  • 🐍 enigma-encryption Python library → published to PyPI
  • 💻 enigma CLI tool → published to GitHub Releases

All hash and cipher logic lives exactly once in core/, shared by both outputs.


Architecture

enigma/
├── core/               # ✅ Single source of truth
│   ├── include/enigma/
│   │   ├── hash.h      # hash_password() API
│   │   ├── cipher.h    # encrypt/decrypt API
│   │   └── primitives.h # Shared internal byte primitives
│   └── src/
│       ├── hash.cpp    # Custom iterative hash algorithm
│       ├── salt.cpp    # CSPRNG + salt generation
│       ├── primitives.cpp # Shared bitwise rotation/manipulation
│       ├── cipher.cpp  # Symmetric encrypt/decrypt of byte buffers
│       └── file_io.cpp # Chunked file encryption/decryption
├── cli/                # C++ CLI → GitHub Releases
├── python/             # pybind11 bindings → PyPI
├── tests/
│   ├── cpp/            # C++ test suite (hash + cipher tests)
│   └── python/         # pytest suite (50+ tests)
├── CMakeLists.txt
├── pyproject.toml      # scikit-build-core configuration
└── .github/workflows/
    ├── ci.yml           # Test on push (Linux, macOS, Windows)
    ├── release-cli.yml  # CLI → GitHub Releases (on tag)
    └── publish-pypi.yml # Python wheel → PyPI (on tag)

CLI

# Build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel

# Hash a password
./build/cli/enigma hash mypassword
./build/cli/enigma hash mypassword 12 myFixedSalt1234

# Encrypt / decrypt files
./build/cli/enigma encrypt secrets.txt mypassword
./build/cli/enigma decrypt secrets.txt.enc mypassword

Cost factor controls iterations (2^cost). Default is 10 (1024 rounds).
Recommended range: 8–14.

File format: Custom binary enigma001 — no system dependencies.


Python Library

Install

pip install enigma-encryption

Usage

import enigma

# Hash a password (random salt generated automatically)
h = enigma.hash_password("mysecret", cost=10)
print(h)  # $aBcD1234567890$/$XYZ…

# Verify later — extract salt and re-hash
salt = enigma.extract_salt(h)
assert enigma.hash_password("mysecret", cost=10, salt=salt) == h

# Encrypt / decrypt bytes
data = b"my secret data"
enc = enigma.encrypt_bytes(data, "password", cost=10)
dec = enigma.decrypt_bytes(enc, "password")
assert dec == data

# Encrypt / decrypt files
enigma.encrypt_file("secret.txt", "secret.enc", "password", cost=10)
enigma.decrypt_file("secret.enc", "secret.txt", "password")

Algorithm

Hashing (hash_password):

  • Multi-stage iterative algorithm: hash1 → hash2 → hash3 → hash4
  • Nth-element byte cycling (custom permutation)
  • Latin-1 → UTF-8 encoding conversion within the hash
  • Memory-hard: each iteration reads from a 16×N memoization table
  • Output: $<salt>$/$<hash> — salt is always embedded

Cipher (encrypt_bytes / encrypt_file):

  • Password → hash_password(password, cost, random_salt) → key
  • Key → hash_password(key, cost, salt) → verification hash
  • Data: iterated rotate_left + XOR in 1 KB sub-chunks
  • File format: enigma001 magic + salt + cost + verification hash + ciphertext

Testing

# C++ tests
cmake -B build && cmake --build build --parallel
cd build && ctest --output-on-failure

# Python tests
pip install . -v
python -m pytest tests/python/ -v

Release

Tag a version to trigger both pipelines:

git tag v1.0.0
git push --tags
  • GitHub Actions builds CLI binaries for Linux, macOS, Windows → GitHub Release
  • GitHub Actions builds Python wheels for all platforms → PyPI

PyPI Setup (one-time)

  1. Register at pypi.org
  2. Go to Account → Publishing → Add a new pending publisher
  3. Fill in: GitHub owner, repo enigma, workflow publish-pypi.yml, env pypi
  4. Push a tag — no secrets needed (Trusted Publishing via OIDC)

License

MIT

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

enigma_encryption-1.0.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distributions

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

enigma_encryption-1.0.0-cp312-cp312-win_amd64.whl (236.8 kB view details)

Uploaded CPython 3.12Windows x86-64

enigma_encryption-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (128.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

enigma_encryption-1.0.0-cp312-cp312-macosx_11_0_arm64.whl (100.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

enigma_encryption-1.0.0-cp311-cp311-win_amd64.whl (236.0 kB view details)

Uploaded CPython 3.11Windows x86-64

enigma_encryption-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

enigma_encryption-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (100.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

enigma_encryption-1.0.0-cp310-cp310-win_amd64.whl (234.8 kB view details)

Uploaded CPython 3.10Windows x86-64

enigma_encryption-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (127.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

enigma_encryption-1.0.0-cp310-cp310-macosx_11_0_arm64.whl (99.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: enigma_encryption-1.0.0.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for enigma_encryption-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dabc9e7974f909b9837208e5d0af9d82937c9cf480501a64d51e2a99a903f756
MD5 c59bc46dd973133830fb98dfa272f99c
BLAKE2b-256 5d8405f6cb0f7af1ff03d73592ff1a16231ba0c262b3432e8c739265cfd1cdfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0.tar.gz:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3f43dae1daee915bb8b3a0fc8c989c6f7cac9d8edbc8df03789ce9f264ae8d59
MD5 c26bfdb07de74ce018418e75d38bd964
BLAKE2b-256 c39c96d6d757229f8f7860d769142130a82ebea64a4abfac9e090f57f380bc80

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp312-cp312-win_amd64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82979c4d66921607578982b84f7ec9e03b577e7ed9174e3c42616f68a64343fb
MD5 561cd6022889306becc3f00e397841fa
BLAKE2b-256 845c39d671ce49685ef024655c53563351e71a99b97cd07422927627f81a18d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5945a4d0cf6c6b9afe8a77fab96258b3e7da1d3c76246057ffa50a78154d0598
MD5 995c3bcf6def2cd876e0d84be0b28cd3
BLAKE2b-256 7f403ac548b15fa23807ef1b5c7f1b8039332fe64985af7bc28946c840f74fb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f2f9a0e4d52ebd2901e4dee898f37eae65ed50b0a0facc2f364586ce96d2c40b
MD5 92c45e92e9f092b6ac20b2b75f76b505
BLAKE2b-256 4d0770d1815baf37f4c0ad7aeb59b543361dc1518f7d2609800a0bb8ed888291

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp311-cp311-win_amd64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2beef7613119249f0a8fc920b7956eda0bb3f2458492d7df4350ce66701aab9b
MD5 f276c457663aaaaecab65072bbf34762
BLAKE2b-256 0e5800a97308de0d504184374643e92e29240693f70795d8cf08755f13feaadb

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43c3ee93ac9391be1f5a629a94cd55a792f5fc7f459630821aa0577100e312d7
MD5 32c4ee66d1471ed1f1c1490c33204acb
BLAKE2b-256 717a4790cfeaa00fd714588dc8f3f70febfda42951120ce1f0c79ff30ae1f689

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5e830c2230974b3276d3f3227d9f280744f41f821ee9d63afb1dd00008b2bd3d
MD5 2481332c499e96639904889e24b5131d
BLAKE2b-256 5b8f9badf8245d6f75ba2a3390963cf71b0d2beaeade2c640f92a8e5e42c40e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp310-cp310-win_amd64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ca4357f90b751f699563c6eb1c142790feafc5f7980d36b12f67ed2ae6d0966
MD5 8bdbb269e60cc31b5aba969931fb0b61
BLAKE2b-256 fdfc3d5a093832a8c281b0ecf00c44cd8e528dad6b33ce9bc27a9282bddd7e46

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enigma_encryption-1.0.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for enigma_encryption-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0a74fc8ec7baa982095ca8d13a43d216873c642f0a9152bf62d4ab454772973
MD5 c7226b3bcb6f754bab588da477d9228f
BLAKE2b-256 b1b337ad10bd76a79a09f61197b3b08e582b0ac6d97f3f2d6089a4c7e90dae41

See more details on using hashes here.

Provenance

The following attestation bundles were made for enigma_encryption-1.0.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on dsainvg/enigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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