CryptoLens is an educational CLI tool designed to help users understand various encryption methods and their underlying principles. It provides step-by-step visual explanations of different encryption algorithms and their processes, making cryptography concepts more accessible and easier to understand.
- π Educational Focus: Perfect for learning cryptography concepts
- π Multiple Algorithms: Support for various encryption methods
- π Visual Learning: Step-by-step process visualization
- π Security First: Best practices and security considerations
- π Modern Features: Latest cryptographic standards
- π¨ Beautiful UI: Colored output and ASCII art
- π± Cross-Platform: Works on Windows, Linux, and macOS
- π Active Development: Regular updates and improvements
- 10+ Encryption Methods
- 6 HMAC Algorithms
- 3 PBKDF Implementations
- 2 Key Exchange Protocols
- 3 JWT Algorithms
- 90%+ Test Coverage
- 100% Security Audited
- 24/7 Community Support
Each algorithm below is fully documented in the /docs
folder. See the linked docs for in-depth technical details, security notes, and troubleshooting.
-
Base64 Encoding
- Binary-to-text encoding
- Step-by-step visualization of the encoding process
- ASCII and binary representations
- Support for both encoding and decoding operations
-
Caesar Cipher
- Classical substitution cipher
- Character-by-character transformation
- Alphabet shift visualization
- Customizable shift value
- Support for both encryption and decryption
-
AES Encryption
- Modern symmetric encryption (AES-256)
- Block cipher operations
- Secure key and IV handling
- Support for both encryption and decryption
- Automatic key generation
-
ChaCha20-Poly1305
- Modern stream cipher with AEAD
- High-performance encryption
- Authentication and encryption in one operation
- Support for both encryption and decryption
- Secure nonce handling
-
SHA-256 Hashing
- Cryptographic hash function
- One-way transformation
- Hash value generation
- Input validation and error handling
-
RSA Encryption
- Asymmetric encryption (RSA-2048)
- Public/private key pair generation
- Secure key storage in project directory
- Support for both encryption and decryption
- Automatic key pair management
- Base64 encoded output for encrypted data
-
HMAC Authentication
- Hash-based Message Authentication Code
- Multiple hash algorithm support:
- SHA-1 (legacy, not recommended)
- SHA-256 (widely used)
- SHA-512 (higher security margin)
- BLAKE2b-256 (faster alternative)
- BLAKE2b-512 (high performance)
- BLAKE3 (latest generation)
- Real-time performance measurements
- Detailed algorithm information
- Step-by-step HMAC process visualization
- Secure key management
- Output in both Hex and Base64 formats
- Built-in benchmarking tool:
- Compare performance of all HMAC algorithms
- Customizable number of iterations
- Sample text input
- Performance recommendations
- Detailed timing statistics
- Percentage-based performance comparison
- Interactive loading animation
- Colored ASCII art visualization
- Proportional scaling for performance bars
-
Password-Based Key Derivation
- Multiple algorithm support:
- PBKDF2 (Password-Based Key Derivation Function 2)
- Argon2id (Memory-Hard Function)
- Scrypt (Memory-Hard Function)
- Configurable parameters:
- Iterations/work factor
- Memory usage (for Argon2id and Scrypt)
- Threads (for Argon2id)
- Key length
- Secure salt generation
- One-way key derivation
- Detailed parameter information
- Security recommendations
- Base64 encoded output
- Colored ASCII art visualization for benchmarks
- Multiple algorithm support:
-
Diffie-Hellman Key Exchange
- Authenticated key exchange implementation
- RSA key pairs for Alice and Bob
- SHA-256 hashing before RSA signing
- Signature verification for key authenticity
- AES-GCM encryption using derived shared secret
- TLS-like protocol demonstration
- MITM prevention measures
- Performance comparison with X25519
-
X25519 Key Exchange
- Modern Curve25519 implementation
- HKDF key derivation
- AES-GCM encryption demo
- Proper scalar validation
- Performance benchmarking
- TLS 1.3 connection flow
- Professional ASCII diagrams
- Security best practices
-
JWT Support
- Multiple algorithm support:
- HS256 (HMAC with SHA-256)
- RS256 (RSA with SHA-256)
- EdDSA (Edwards-curve Digital Signature Algorithm)
- JWT processor configuration
- Secret key management
- Token generation and verification
- Claims handling
- Expiration management
- Multiple algorithm support:
-
ECB Mode Vulnerability
- Demonstrates the weakness of Electronic Codebook (ECB) mode
- Shows how patterns in plaintext are preserved in ciphertext
- Visual representation of block patterns
- Real-world examples of ECB vulnerabilities
-
Nonce Reuse in AEAD
- Simulates the catastrophic effects of nonce reuse in ChaCha20-Poly1305
- Demonstrates how nonce reuse breaks confidentiality
- Shows practical examples of nonce reuse attacks
- Best practices for nonce management
-
Timing Attack on HMAC
- Simulates timing side-channel attacks on HMAC verification
- Demonstrates constant-time comparison importance
- Shows how timing differences can leak information
- Countermeasures and secure implementations
-
Brute Force Attacks
- Simulates brute force attacks on weak keys and passwords
- Demonstrates password strength importance
- Shows time estimates for different key lengths
- Best practices for key and password generation
-
JWT None Algorithm Attack
- Demonstrates the vulnerability of accepting "none" algorithm
- Shows how to forge valid JWTs without a secret
- Explains proper JWT algorithm validation
- Security best practices for JWT implementation
- Interactive CLI interface with intuitive menu system
- Real-time step-by-step encryption process visualization
- Detailed explanations of each algorithm's principles
- Binary, hexadecimal, and ASCII representations
- Educational notes and security considerations
- Input validation and error handling
- Factory pattern for encryption method selection
- Modular and extensible architecture
- Secure key storage in project directory
- Cross-platform compatibility (Windows, Linux, macOS)
- Performance measurements for HMAC algorithms
- Comprehensive algorithm information display
- Interactive loading animations for long operations
- Version number display in welcome message
- Colored ASCII art visualization for benchmarks
- TLS 1.3 connection flow documentation
- Professional ASCII diagrams for key exchange
- Security warnings and best practices
- Go 1.21 or higher
- Git (for installation from source)
go install github.com/abdorrahmani/cryptolens@latest
# Clone the repository
git clone https://github.com/abdorrahmani/cryptolens.git
# Navigate to project directory
cd cryptolens
# Build the project
go build -o cryptolens cmd/cryptolens/main.go
# Move the binary to your PATH (optional)
mv cryptolens /usr/local/bin/
Run the program:
cryptolens
The program will present you with an interactive menu:
- Choose an encryption method (1-10)
- Enter your text
- View the detailed encryption process and explanation
- See the final result
- Encryption keys are stored in the
keys
directory in the project root - RSA keys are stored as PEM files
- AES keys are stored as binary files
- HMAC keys are stored as binary files
- The
keys
directory is automatically created on first run - Keys are securely stored with appropriate file permissions
Encryption Process Visualization:
=================================
Base64 Encoding Process
=====================
Original Text: Hello
β
ASCII Values: 48 65 6c 6c 6f
β
Binary Representation: 01001000 01100101 01101100 01101100 01101111
β
Base64 Encoded: SGVsbG8=
=================================
Decryption Process Visualization:
=================================
Base64 Decoding Process
=====================
Base64 Encoded Text: SGVsbG8=
β
ASCII Values: 48 65 6c 6c 6f
β
Binary Representation: 01001000 01100101 01101100 01101100 01101111
β
Decoded Text: Hello
=================================
HMAC Example (SHA-256):
=================================
HMAC Process
Input Text: Hello
β
HMAC Key: [secure key]
β
HMAC Result (Hex): [64 characters]
HMAC Result (Base64): [44 characters]
=================================
PBKDF Example (Argon2id):
=================================
Using argon2id for key derivation
Salt (base64): [random salt]
β
Argon2id Parameters:
- Iterations: 100000
- Memory: 65536 KB
- Threads: 4
- Key Length: 256 bits
β
Derived Key (base64): [derived key]
=================================
X25519 Key Exchange:
=================================
Alice's Public Key: [32 bytes]
Bob's Public Key: [32 bytes]
β
Shared Secret: [32 bytes]
β
AES-GCM Encrypted Message: [encrypted data]
=================================
JWT Example (RS256):
=================================
JWT Header: {"alg":"RS256","typ":"JWT"}
β
JWT Payload: {"sub":"1234567890","name":"John Doe"}
β
JWT Signature: [signature]
β
Final JWT: [header].[payload].[signature]
=================================
cryptolens/
βββ cmd/
β βββ cryptolens/
β βββ main.go # Application entry point
βββ internal/
β βββ crypto/ # Encryption implementations
β β βββ base64.go # Base64 encoding/decoding
β β βββ caesar.go # Caesar cipher implementation
β β βββ aes.go # AES encryption/decryption
β β βββ chacha20poly1305.go # ChaCha20-Poly1305 implementation
β β βββ sha256.go # SHA-256 hashing
β β βββ rsa.go # RSA encryption/decryption
β β βββ hmac.go # HMAC implementation
β β βββ pbkdf.go # PBKDF implementation
β β βββ dh.go # Diffie-Hellman implementation
β β βββ x25519.go # X25519 implementation
β β βββ jwt.go # JWT implementation
β β βββ interfaces.go # Encryption processor interface
β β βββ keymanager.go # Key management
β βββ cli/ # CLI interface components
β β βββ menu.go # Interactive menu system
β β βββ display.go # Output formatting
β β βββ input.go # User input handling
β β βββ interfaces.go # Interface definitions
β β βββ factory.go # Encryption method factory
β βββ config/ # Configuration management
β β βββ config.go # Configuration handling
β βββ utils/ # Utility functions
β β βββ visualizer.go # Process visualization
β β βββ theme.go # Color theme management
β βββ input/ # Input handling
β β βββ input.go # Input processing
β βββ benchmark/ # Benchmarking tools
β βββ benchmark.go # Performance measurement
βββ keys/ # Encryption keys storage
β βββ rsa_private.pem # RSA private key
β βββ rsa_public.pem # RSA public key
β βββ aes_key.bin # AES key
β βββ hmac_key.bin # HMAC key
β βββ dh_private.pem # DH private key
β βββ dh_public.pem # DH public key
β βββ x25519_private.pem # X25519 private key
β βββ x25519_public.pem # X25519 public key
βββ assets/ # Project assets
βββ config/ # Configuration files
β βββ config.yaml # Default configuration
βββ LICENSE
βββ README.md
# Clone the repository
git clone https://github.com/abdorrahmani/cryptolens.git
# Navigate to project directory
cd cryptolens
# Build the project
go build -o cryptolens cmd/cryptolens/main.go
# Run tests
go test ./...
- Create a new encryption implementation in
internal/crypto/
- Implement the required interfaces
- Add the new method to the factory in
internal/cli/factory.go
- Update the menu system in
internal/cli/menu.go
- Add appropriate tests
- Update configuration in
config/config.yaml
We welcome contributions! Please see our Contributing Guide for details.
# Fork and clone
git clone https://github.com/abdorrahmani/cryptolens.git
cd cryptolens
# Install dependencies
go mod download
# Run tests
go test ./...
# Build
go build -o cryptolens cmd/cryptolens/main.go
- Follow Go best practices
- Write comprehensive tests
- Update documentation
- Add examples
- Follow security guidelines
Algorithm | Time (Β΅s) | Relative Speed
-------------|-----------|---------------
BLAKE3 | 0.5 | 100%
BLAKE2b-512 | 0.8 | 62.5%
SHA-512 | 1.2 | 41.7%
SHA-256 | 1.5 | 33.3%
SHA-1 | 1.8 | 27.8%
Algorithm | Time (ms) | Memory (MB) | Security Level
----------|-----------|-------------|---------------
Argon2id | 100 | 64 | High
Scrypt | 120 | 32 | High
PBKDF2 | 150 | 1 | Medium
- π Education: Learn cryptography concepts
- π Development: Test encryption implementations
- π Security: Verify cryptographic operations
- π Research: Experiment with different algorithms
- π οΈ Testing: Validate cryptographic functions
- π Benchmarking: Compare algorithm performance
This project is licensed under the MIT License - see the LICENSE file for details.
- Go Standard Library for cryptographic functions
- The cryptography community for educational resources
- BLAKE3 team for their fast and secure hash function
- All contributors who help improve this project
- GitHub: @abdorrahmani
- Project Link: https://github.com/abdorrahmani/cryptolens