A simple, interactive command-line tool for encrypting and decrypting messages using classic algorithms. Designed for encryption enthusiasts and Java students.
- Encrypt & Decrypt: Choose between two modes.
- Algorithms:
- ROT13: A classic shift cipher (shift by 13).
- Atbash: Reverses the alphabet (A -> Z, B -> Y).
- Caesar Cipher: A historical cipher with a fixed shift of 3.
- Robust Input: handles invalid inputs options and empty strings gracefully.
- Compile:
javac Main.java CypherTool.java
- Run:
java Main
Welcome to the Cypher Tool!
Select operation:
1. Encrypt
2. Decrypt
$> 1
Select cypher:
1. ROT13
2. Atbash
3. Caesar (Shift 3)
$> 1
Enter the message:
$> Hello World!
Encrypted message (ROT13):
Uryyb Jbeyq!
The main() method controls the entire program:
1. Display welcome message
2. Loop forever:
a. Ask user: Encrypt, Decrypt, or Exit?
b. If Exit → quit program
c. Ask which cipher to use
d. Ask for message input
e. Validate input
f. Process message (encrypt or decrypt)
g. Display result
h. Go back to step 2
Key Concept: The loop allows users to process multiple messages without restarting the program.
What it does: Shifts each letter 13 positions forward in the alphabet.
Visual Example:
Original: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
ROT13: N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
H e l l o → U r y y b
(shift 13)
Why ROT13 is special: Applying ROT13 twice gives you the original message back!
"Hello" → ROT13 → "Uryyb" → ROT13 → "Hello"
Code Logic:
(c - 'A' + 13) % 26c - 'A'= position in alphabet (0-25)+ 13= shift by 13% 26= wrap around using modulo (when we go past Z, wrap to A)
Example: H (position 7) → (7 + 13) % 26 = 20 → U
Main.java: Entry point.CypherTool.java: Contains all logic and encryption algorithms.STUDY_GUIDE.md: Explains the math and logic behind the code.pseudocode.txt: High-level logic overview.presentation.md: preparation for project presentation to tutors.