LightCrypt is a custom 128-bit encryption algorithm I built from scratch as my first project in learning cryptography. It's specifically designed for small, low-power devices like IoT sensors, smart home gadgets, and embedded systems that need to encrypt data but have limited processing power and battery life.
Traditional encryption algorithms like AES can be too heavy for tiny devices. LightCrypt solves this by being:
- Lightweight: Uses minimal memory and processing power
- Fast: Optimized for quick encryption/decryption
- Secure: Still provides strong data protection
LightCrypt uses a Substitution-Permutation Network (SPN) - a proven cryptographic structure that:
- Substitutes data using lookup tables (adds confusion)
- Permutes bits around (spreads changes across the data)
- Repeats this process 10 times with different keys
Technical Specs
- Block Size: 128 bits (16 bytes at a time)
- Key Size: 128-bit encryption key
- Rounds: 10 cycles of substitution and permutation
- Structure: Substitution-Permutation Network (SPN)
Perfect for: IoT sensors, Arduino projects, battery-powered devices, and learning cryptography fundamentals.
Plaintext (128 bits) → AddRoundKey → [SubBytes → ShiftRows → AddRoundKey] × 10 rounds → Ciphertext
- Confusion: Makes relationship between key and ciphertext complex (S-box)
- Diffusion: Spreads influence of single plaintext bit across many ciphertext bits (permutation)
- Key Schedule: Generates round keys from master key
- Rounds: Multiple iterations increase security
│── src/ │ └── lightcrypt.py # Core cipher implementation │── demo/ │ └── demo.py # Example encryption/decryption usage │── test/ │ └── test_lightcrypt.py # Unit tests (pytest) │── benchmark/ │ ├── standard_benchmark.py # Benchmark LightCrypt only │ └── compare_benchmark.py # Compare LightCrypt vs AES |── encrypt.py |── decrypt.py │── README.md
Clone the repository and install dependencies:
git clone https://github.com/DivInstance/lightweight-cryptographic-algorithm
cd lightweight-cryptography-algorithm
pip install -r requirements.txt
- Python 3.11+
- pytest for testing
- pycryptodome for AES benchmark
From the project root directory:
python -m encrypt
python -m decrypt
python -m src.lightcrypt
Alter the message value to encrypt/decrypt in the main function your own message.
Run the demo to see example encryption/decryption on IoT-style payloads:
python -m src.demo
Unit tests (pytest):
pytest -v
python -m benchmark.compare_benchmark
Results (500 iterations, ECB mode)
Encryption: 4.1924 sec (119.26 KB/s) Decryption: 4.2446 sec (117.80 KB/s)
Encryption: 0.0034 sec (146838.82 KB/s) Decryption: 0.0030 sec (165573.35 KB/s)
- Raspberry Pi Optimization & IoT Testing : Test LightCrypt on actual Raspberry Pi hardware to measure real-world IoT benchmarks.
- Statistical Security Analysis & Randomness Testing: Perform NIST tests and avalanche analysis to validate cryptographic security.
- CBC Mode Implementation & Hardware Translation: Add CBC mode and create a C version for microcontroller/Arduino deployment.
This is my first project in cryptography. I built LightCrypt (LCA-128) to learn and understand the principles of block ciphers and secure coding.
References and resources that helped in designing the Substitution–Permutation Network (SPN) structure:
- Cryptography textbooks and online resources on SPN ciphers
- Research papers on lightweight block ciphers for IoT and embedded systems
- Practical examples of AES and other standard block ciphers
This project is licensed under the MIT License – free to use, modify, and distribute.