The Caesar Cipher Tool is a web-based application that enables users to encrypt and decrypt messages using one of the earliest known encryption methods. The tool implements the Caesar Cipher, a substitution cipher that shifts each letter in the plaintext by a fixed number of positions down the alphabet. Built to focus on educational value and user experience, it offers a user-friendly interface for understanding basic cryptographic concepts.
To install and run the Caesar Cipher Tool locally, follow these steps:
- Clone the project repository:
git clone https://github.com/RobCyberLab/Caesar-Cipher-Tool.git
- Navigate to the project directory:
cd src
- Open the
index.html
file in your preferred web browser.
- Access the Caesar Cipher Tool by opening index.html in your web browser
- The interface presents two main sections:
- Input Section
- Enter the text you want to process
- Select operation mode (Encode or Decode)
- Set the shift value (1-25)
- Click "Apply" button
- Output Section
- View the processed text result
- Use "Copy" button to copy the result
- Input Section
- The application will display:
- The encoded/decoded result in the output area
- Any error messages if input validation fails
The Caesar Cipher implementation includes distinct handling for letters and numbers:
- Case-sensitive processing
- Modulo 26 operation for alphabet bounds
- ASCII code manipulation
// Letter Shifting
let code = char.charCodeAt(0);
let baseCode = char === char.toUpperCase() ? 65 : 97;
code = (code - baseCode + shift) % 26 + baseCode;
char = String.fromCharCode(code);
- Modulo 10 operation for digit bounds
- ASCII adjustment for numeric values
// Number Shifting
char = String.fromCharCode((char.charCodeAt(0) - 48 + shift) % 10 + 48);
Input:
hello
Shift: 3 Output:
khoor
Example 1: Encoding "hello" with a shift of 3
Input:
khoor
Shift: 3 Output:
hello
Example 2: Decoding "khoor" with a shift of 3
Input:
Hello, World!
Shift: 5 Output:
Mjqqt, Btwqi!
Example 3: Encoding "Hello, World!" with a shift of 5
Input:
Cipher123
Shift: 7 Output:
Jpwoly890
Example 4: Encoding "Cipher123" with a shift of 7
Note: The application includes several features to enhance usability:
- Case preservation for letters
- Special character preservation
- Number shifting with modulo 10
- Input validation
- Copy to clipboard functionality
- Real-time error messaging
These features ensure a smooth user experience while maintaining the educational value of the classical Caesar cipher implementation.