A pure Python encryption library supporting a variety of algorithms and modes
Project description
KatCrypt
A pure Python cryptographic library implementing multiple block ciphers and encryption modes from scratch.
Overview
KatCrypt provides implementations of modern block ciphers and standard modes of operation, built entirely in Python without external cryptographic dependencies. All algorithms are implemented from their original specifications with comprehensive test vector validation.
Supported Algorithms
Block Ciphers
- AES (Advanced Encryption Standard) - 128, 192, and 256-bit keys
- MARS - IBM's AES competition finalist
- Threefish - Block cipher from the Skein hash function family
Modes of Operation
- ECB (Electronic Code Book)
- CBC (Cipher Block Chaining)
- CFB (Cipher Feedback)
- OFB (Output Feedback)
- CTR (Counter Mode)
- GCM (Galois/Counter Mode with authentication)
Installation
From PyPI
pip install katcrypt
From Source
git clone https://github.com/hashwalker/katcrypt.git
Requirements
- Python 3.7+
- No external dependencies
Usage
API
from katcrypt.ciphers.aes import AES
from katcrypt.modes.cbc import CBC
from katcrypt.utils import generate_key, generate_iv
# Setup
key = generate_key(256)
iv = generate_iv(16)
plaintext = b"Object-oriented encryption example!"
print(f"Original: {plaintext}")
# Create cipher and mode objects
cipher = AES(key=key)
mode = CBC(cipher)
# Encrypt and decrypt
ciphertext = mode.encrypt(plaintext, iv)
print(f"Encrypted: {ciphertext.hex()}")
decrypted = mode.decrypt(ciphertext, iv)
print(f"Decrypted: {decrypted}")
print(f"Success: {plaintext == decrypted}")
Project Structure
katcrypt/
├── ciphers/ # Block cipher implementations
├── modes/ # Mode of operation implementations
├── utils.py # Cryptographic utilities
├── constants/ # Algorithm constants and tables
└── test_vectors/ # Test vectors and validation
Testing
The library includes comprehensive test vectors from official sources:
python test_vectors/aes_test_vectors.py
python test_vectors/mars_test_vectors.py
python test_vectors/threefish_test_vectors.py
Test vectors validate against:
- NIST AES test vectors
- IBM MARS reference implementation
- Threefish reference vectors
Security Notice
This library is intended for educational and research purposes only.
It is not suitable for production use as it lacks:
- Constant-time implementations
- Side-channel attack protections
- Formal security audits
- Timing attack mitigations
For production applications, use established libraries such as cryptography or pycryptodome.
License
MIT License - see LICENSE file for details.
Author
Created by hashwalker
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file katcrypt-0.1.4.tar.gz.
File metadata
- Download URL: katcrypt-0.1.4.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71c9ce3f2e9083d292ee3c1b83343b47197908a632753ef4f16a61a2cec00739
|
|
| MD5 |
7cebcc15478adb3f2ab71676fc25595b
|
|
| BLAKE2b-256 |
ba5c8c3e88706fd87838c15d2b5321cf75a932e66fed7809b2f6f76f58729b5d
|
File details
Details for the file katcrypt-0.1.4-py3-none-any.whl.
File metadata
- Download URL: katcrypt-0.1.4-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db9055590fd57222ef133db91d987da595da94b60c6980fedb9f7c9980a57396
|
|
| MD5 |
ea24b133855d14fa52aeccbfa61e6ed7
|
|
| BLAKE2b-256 |
5408c729a90c56f3537eacb0792e1f46724f55177748d82db3fc116bb9fcab90
|