A comprehensive performance benchmarking suite comparing encryption algorithms across Go and Java implementations.
This project benchmarks the performance of three major encryption algorithms implemented in both Go and Java:
- AES-256-GCM (Authenticated Encryption)
- AES-256-CBC (Block Cipher with PKCS#7 padding)
- PGP (RSA-4096 + AES-256 hybrid encryption)
Algorithm | Language | 1KB Throughput | 5MB Throughput | Best Use Case |
---|---|---|---|---|
AES-256-GCM | Go | 358,038 ops/sec | 373 ops/sec | High-frequency APIs |
AES-256-GCM | Java | 10,162 ops/sec | 163 ops/sec | Enterprise systems |
AES-256-CBC | Go | 155,860 ops/sec | 86 ops/sec | Legacy compatibility |
AES-256-CBC | Java | 42,895 ops/sec | 110 ops/sec | Large file processing |
PGP | Go | 168 ops/sec | 4 ops/sec | Key exchange |
PGP | Java | 134 ops/sec | 8 ops/sec | Email encryption |
π Winner: Go + AES-256-GCM for high-performance applications (up to 35x faster than Java)
- Go 1.24+
- Java 11+
- Maven 3.6+
git clone https://github.com/harshitsidhwa/cipher-bench.git
cd cipher-bench
# Run Go benchmarks
cd go-benchmarks
go run .
# Run Java benchmarks
cd ../java-benchmarks
mvn compile exec:java -Dexec.mainClass="com.benchmark.SimpleBenchmarkRunner"
cipher-bench/
βββ π ENCRYPTION_PERFORMANCE_REPORT.md # Comprehensive analysis report
βββ πΉ go-benchmarks/ # Go implementation
β βββ main.go # Benchmark runner
β βββ aes_gcm.go # AES-GCM implementation
β βββ aes_cbc.go # AES-CBC implementation
β βββ pgp.go # PGP implementation
β βββ utils.go # Utility functions
β βββ benchmark_results.json # Go results
βββ β java-benchmarks/ # Java implementation
β βββ pom.xml # Maven configuration
β βββ src/main/java/com/benchmark/
β β βββ SimpleBenchmarkRunner.java # Main benchmark runner
β β βββ AESGCMBenchmark.java # JMH AES-GCM benchmarks
β β βββ AESCBCBenchmark.java # JMH AES-CBC benchmarks
β β βββ SimplePGPBenchmark.java # PGP implementation
β β βββ PGPTest.java # PGP validation test
β βββ java_benchmark_results.json # Java results
βββ π README.md # This file
- Libraries: Standard
crypto/*
+golang.org/x/crypto/openpgp
- Strengths: Native crypto optimizations, excellent small payload performance
- Best for: Microservices, APIs, real-time processing
- Libraries:
javax.crypto
+ Bouncy Castle for PGP - Strengths: Enterprise ecosystem, competitive large payload performance
- Best for: Enterprise applications, complex cryptographic workflows
Payload Size | Go AES-GCM | Java AES-GCM | Go Advantage |
---|---|---|---|
1 KB | 358,038 ops/sec | 10,162 ops/sec | 35.2x faster |
10 KB | 197,550 ops/sec | 13,899 ops/sec | 14.2x faster |
50 KB | 41,729 ops/sec | 22,530 ops/sec | 1.9x faster |
100 KB | 15,124 ops/sec | 11,420 ops/sec | 1.3x faster |
200 KB | 10,370 ops/sec | 7,165 ops/sec | 1.4x faster |
5 MB | 373 ops/sec | 163 ops/sec | 2.3x faster |
Chart-ready CSV data is available in the comprehensive report.
Choose: Go + AES-256-GCM
- Microservices and APIs
- Real-time data processing
- IoT and edge computing
- Systems programming
Choose: Java + AES-256-GCM/CBC
- Large file processing
- Existing Java infrastructure
- Complex integration requirements
- Rich cryptographic workflows
Choose: Either Language + PGP
- Email encryption
- Document signing
- Key exchange protocols
- Certificate management
cd go-benchmarks
# Standard benchmarks
go run .
# Custom payload sizes (modify PayloadSizes in main.go)
# Custom iteration counts (modify iterations in benchmark functions)
# Build optimized binary
go build -o cipher-bench .
./cipher-bench
cd java-benchmarks
# Run all benchmarks
mvn compile exec:java -Dexec.mainClass="com.benchmark.SimpleBenchmarkRunner"
# Test PGP implementation
mvn compile exec:java -Dexec.mainClass="com.benchmark.PGPTest"
# Build JAR (note: signature issues with shaded JAR)
mvn clean package
cd java-benchmarks
# Individual algorithm benchmarks using JMH directly
mvn compile exec:java -Dexec.mainClass="com.benchmark.AESGCMBenchmark"
mvn compile exec:java -Dexec.mainClass="com.benchmark.AESCBCBenchmark"
- 1 KB (1,024 bytes) - Small API responses
- 10 KB (10,240 bytes) - Medium documents
- 50 KB (51,200 bytes) - Large documents
- 100 KB (102,400 bytes) - Small files
- 200 KB (204,800 bytes) - Medium files
- 5 MB (5,242,880 bytes) - Large files
- AES-256: NIST-approved, quantum-resistant
- GCM Mode: Authenticated encryption (AEAD)
- CBC Mode: Industry standard with PKCS#7 padding
- RSA-4096: Strong asymmetric encryption
- PGP: OpenPGP standard compliance
- Cryptographically secure random key generation
- Keys generated outside benchmark loops
- No key reuse across different payload sizes
- Proper IV/nonce generation for each operation
Contributions are welcome! Please read our Contributing Guidelines before submitting pull requests.
- Additional encryption algorithms (ChaCha20-Poly1305, XSalsa20, etc.)
- More language implementations (Rust, Python, C++)
- Performance optimizations
- Additional payload size testing
- Platform-specific benchmarks (ARM, x86, cloud environments)
This project is licensed under the MIT License - see the LICENSE file for details.
- π Complete Performance Report - Detailed analysis and recommendations
- π Go Crypto Package Documentation
- β Java Cryptography Architecture
- π Bouncy Castle Documentation
π WINNER: Go + AES-256-GCM
π Performance: Up to 35x faster than Java
π― Best for: High-frequency encryption, APIs, microservices
β‘ Throughput: 358,038 operations/second (1KB payloads)
Built with β€οΈ for the cryptography and performance engineering community