A comprehensive Java library implementing various classical and modern cryptographic algorithms, developed for the MAT200 course at Northeastern University.
This library provides implementations of multiple cipher algorithms ranging from simple classical ciphers to modern RSA encryption. Each cipher includes both encryption and decryption capabilities with an interactive console interface for testing and demonstration.
- Bacon Cipher - Binary encoding using A/B patterns
- Space Break Cipher - Simple space removal encoding
- Every Nth Letter Cipher - Extract patterns by position
- Reverse Cipher - Character order reversal
- Transposition Cipher - Column-based rearrangement with numeric or word keys
- Caesar Cipher - Alphabet shifting with numeric or keyword-based shifts
- Multiplicative Cipher - Modular multiplication-based substitution
- Affine Cipher - Combination of multiplicative and additive ciphers
- Vigenère Cipher - Keyword-based polyalphabetic substitution
- RSA Cipher - Public-key cryptography with key generation and file I/O
- Java 17 or higher
- Maven 3.6 or higher
- Clone the repository:
git clone https://github.com/snxethan/MAT200-LIBRARY.git
cd MAT200-LIBRARY- Build the project:
mvn compile- Run the interactive console:
mvn exec:java -Dexec.mainClass="NEU.ET39.MAT200.Main"The main application provides an interactive menu system to test all cipher implementations:
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
runConsole(scanner);
scanner.close();
}// Encrypt with shift
String encrypted = CaesarCipher.encryptByShift("HELLO WORLD", 3);
// Result: "KHOOR ZRUOG"
// Decrypt with shift
String decrypted = CaesarCipher.decryptByShift("KHOOR ZRUOG", 3);
// Result: "HELLO WORLD"
// Encrypt with keyword
String encrypted = CaesarCipher.encryptByKeyWord("HELLO", "SECRET");
// Uses keyword to generate substitution alphabet// Encrypt with keyword
String encrypted = VigenereCipher.encrypt("ATTACK AT DAWN", "LEMON");
// Result: "LXFOPV EF RNHR"
// Decrypt with keyword
String decrypted = VigenereCipher.decrypt("LXFOPV EF RNHR", "LEMON");
// Result: "ATTACK AT DAWN"RSACipher rsa = new RSACipher();
// Save keys to file
rsa.savePublicKeyOnly("public_key.txt");
rsa.savePrivateKeyOnly("private_key.txt");
// Load and encrypt
BigInteger[] publicKey = RSACipher.loadPublicKeyFromTxt("public_key.txt");
BigInteger encrypted = rsa.encryptBlock("Hello RSA!", publicKey[0], publicKey[1]);
// Load and decrypt
BigInteger[] privateKey = RSACipher.loadPrivateKeyFromTxt("private_key.txt");
rsa.loadPrivateKey(privateKey[0], privateKey[1]);
String decrypted = rsa.decryptBlock(encrypted);The project includes JUnit tests. Run them with:
mvn testsrc/
├── main/java/NEU/ET39/MAT200/
│ ├── Main.java # Interactive console interface
│ ├── AffineCipher.java # Affine cipher implementation
│ ├── BaconCipher.java # Bacon cipher implementation
│ ├── CaesarCipher.java # Caesar cipher implementation
│ ├── EveryNthCipher.java # Every nth letter cipher
│ ├── MultiplicativeCipher.java # Multiplicative cipher implementation
│ ├── RSACipher.java # RSA cipher implementation
│ ├── ReverseCipher.java # Reverse cipher implementation
│ ├── SpaceBreakCipher.java # Space break cipher implementation
│ ├── TranspositionCipher.java # Transposition cipher implementation
│ └── VigenereCipher.java # Vigenère cipher implementation
└── test/java/
└── BaconCipherTest.java # Unit tests
- Interactive Console: Menu-driven interface for all ciphers
- File I/O Support: RSA cipher supports key file generation and loading
- Multiple Input Methods: Support for both programmatic and console input
- Comprehensive Error Handling: Input validation and error messages
- Educational Output: Displays cipher alphabets and transformation steps
- Key Length: 1024-bit keys for security
- Key Generation: Uses
SecureRandomfor cryptographically secure random numbers - File Format: Keys saved in readable text format
- Block Processing: Handles message size limitations
- Case Preservation: Maintains original character casing
- Non-alphabetic Character Handling: Preserves spaces and punctuation
- Alphabet Display: Shows plaintext/ciphertext alphabet mappings
- Input Validation: Checks for valid keys and parameters
This library is structured to align with the MAT200 curriculum:
- Unit 1: Basic encoding and simple transformations
- Unit 2: Transposition-based cryptography
- Unit 3: Substitution cipher theory and implementation
- Unit 4: Advanced polyalphabetic methods
- Final Project: Modern public-key cryptography
This is a course project repository. For educational purposes, please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add appropriate tests
- Submit a pull request
This project is developed for educational purposes as part of the MAT200 course at Northeastern University.