LANA-1028: A custom encryption algorithm.
Project description
LANA1028 Cipher
A 1028-bit educational encryption cipher implementation with modern cryptographic features.
⚠️ Important Notice
This is an educational implementation and should NOT be used for production systems or real data protection. For production use, always rely on established cryptographic libraries like AES-256-GCM, ChaCha20-Poly1305, or similar industry-standard algorithms.
Features
✔ Nonlinear S-box table - AES-style substitution for proper nonlinearity
✔ Byte mixing per round - Diffusion layer for spreading changes across the block
✔ IV mixing every round - Proper initialization vector usage
✔ Strict unpad checking - Protection against padding oracle attacks
✔ 64 rounds - Multiple transformation rounds for security
✔ 512-bit block size - Large block size for reduced block operations
Installation
pip install lana1028
Quick Start
from lana1028.main import generate_lana1028_key, lana1028_encrypt, lana1028_decrypt
# Generate a secure random key
key = generate_lana1028_key()
# Encrypt a message
message = "This is a secret message!"
encrypted = lana1028_encrypt(message, key)
print(f"Encrypted: {encrypted}")
# Decrypt the message
decrypted = lana1028_decrypt(encrypted, key)
print(f"Decrypted: {decrypted}")
API Reference
generate_lana1028_key()
Generates a cryptographically secure random 1028-bit (129-byte) key.
Returns: bytes - A 129-byte key
Example:
key = generate_lana1028_key()
# Save this key securely - you'll need it to decrypt!
lana1028_encrypt(plaintext, key)
Encrypts plaintext using the LANA1028 cipher.
Parameters:
plaintext(str or bytes) - The message to encryptkey(bytes) - A 129-byte key fromgenerate_lana1028_key()
Returns: str - Base64-encoded ciphertext
Example:
encrypted = lana1028_encrypt("Secret data", key)
lana1028_decrypt(ciphertext, key)
Decrypts ciphertext using the LANA1028 cipher.
Parameters:
ciphertext(str) - Base64-encoded encrypted datakey(bytes) - The same 129-byte key used for encryption
Returns: str - Decrypted plaintext
Raises: ValueError - If padding is invalid (tampered ciphertext)
Example:
try:
decrypted = lana1028_decrypt(encrypted, key)
except ValueError as e:
print(f"Decryption failed: {e}")
Examples
Basic Encryption/Decryption
from lana1028.main import generate_lana1028_key, lana1028_encrypt, lana1028_decrypt
# Generate key
key = generate_lana1028_key()
# Encrypt
plaintext = "Hello, World!"
ciphertext = lana1028_encrypt(plaintext, key)
# Decrypt
decrypted = lana1028_decrypt(ciphertext, key)
assert plaintext == decrypted # ✓
Encrypting Bytes
# You can encrypt bytes directly
data = b"Binary data \x00\x01\x02"
encrypted = lana1028_encrypt(data, key)
decrypted = lana1028_decrypt(encrypted, key)
Key Storage
import os
# Generate and save key
key = generate_lana1028_key()
with open("secret.key", "wb") as f:
f.write(key)
# Load key later
with open("secret.key", "rb") as f:
loaded_key = f.read()
# Use the loaded key
message = "Secure message"
encrypted = lana1028_encrypt(message, loaded_key)
Error Handling
from lana1028.main import lana1028_decrypt
try:
# Attempt to decrypt with wrong key or tampered data
decrypted = lana1028_decrypt(bad_ciphertext, key)
except ValueError as e:
print(f"Decryption failed - data may be corrupted: {e}")
Security Considerations
✅ What This Cipher Does
- Provides confidentiality through encryption
- Detects tampering via padding validation
- Uses cryptographically secure random IV generation
- Implements nonlinear transformations
❌ What This Cipher Does NOT Do
- Not audited - This is educational code, not reviewed by cryptographers
- No authentication - Doesn't provide authenticated encryption (no MAC/AEAD)
- No key derivation - Use proper KDFs like PBKDF2 if deriving keys from passwords
- Not optimized - Performance is not production-grade
For Production Use
Use established libraries instead:
# Use this for real applications:
from cryptography.fernet import Fernet
# Or for more control:
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
Technical Details
- Key Size: 1028 bits (129 bytes)
- Block Size: 512 bits (64 bytes)
- Rounds: 64
- IV Size: 64 bytes (randomly generated per encryption)
- Padding: PKCS7-style
- Output Format: Base64-encoded
Algorithm Overview
- Key Expansion - Derives 64 round keys using SHA-512
- Padding - PKCS7 padding to block boundary
- Per Round:
- IV mixing with round-specific transformation
- XOR with round key
- Nonlinear S-box substitution
- Byte mixing (diffusion layer)
- Permutation
License
MIT License - See LICENSE file for details
Contributing
This is an educational project. If you spot issues or want to suggest improvements for learning purposes, feel free to open an issue or pull request.
Disclaimer
EDUCATIONAL USE ONLY. This cipher is not suitable for protecting real sensitive data. Always use industry-standard cryptographic libraries for production applications.
Project details
Release history Release notifications | RSS feed
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 lana1028-0.1.6.1.tar.gz.
File metadata
- Download URL: lana1028-0.1.6.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d02d6bb470791a54bd441248fee2c45052f40994741c4061b5c1263665dc6b88
|
|
| MD5 |
cc653a12cf7f6e88910d51461d7a04a9
|
|
| BLAKE2b-256 |
e60790a3a193f14d11b237c84a91087a52706205854279c453e5f140312cde38
|
File details
Details for the file lana1028-0.1.6.1-py3-none-any.whl.
File metadata
- Download URL: lana1028-0.1.6.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e5f868a3463ad0a72dafc6ff3cb59ad537582c02061dff1680af92223e273f9
|
|
| MD5 |
cdd6e68cb5b69b3cb645f772f556ed5d
|
|
| BLAKE2b-256 |
b2c80757f14f7d17f3d5e92f29acd176744de9de67ef002f0d2d5d5c468e3d84
|