This project is a simple Caesar Cipher Decoder written in PHP.
It takes an encoded text and a numeric shift value, and returns the decoded message.
A Caesar cipher is a basic encryption technique in which each letter in a message is replaced
by another letter a fixed number of positions down the alphabet.
Example:
Plain text: HELLO
Shift: 3
Encoded: KHOOR
Decoding reverses this shift to recover the original message.
- PHP 7.0+ installed on your system (macOS already includes PHP by default).
You can check your version by running:php -v
- Clone or download this project to your computer.
You can pass the encoded text and shift value directly from the terminal.
php decoder.php "Mjqqt Btwqi" 5Output:
Decoded text: Hello World
If no arguments are provided, the script runs a built-in example automatically:
php decoder.phpOutput:
No arguments provided. Running example...
Encoded text: Aopz pz aol huzdly, dlss kvul!
Shift: 7
Decoded text: This is the answer, well done!
- Each alphabetic character is shifted back by the given
$shiftvalue. - Uppercase and lowercase letters are preserved.
- Non-alphabetic characters (spaces, punctuation, etc.) are not changed.
- The alphabet “wraps around” — shifting
'A'back by 1 becomes'Z'.
| Encoded Text | Shift | Expected Output |
|---|---|---|
Czggj Rjmgy |
5 | Hello World |
Dpef! Xibu jt uijt? |
1 | Code! What is this? |
Olssv Dvysk |
33 | Hello World |
Aopz pz aol huzdly, dlss kvul! |
7 | This is the answer, well done! |
This project is open-source and free to use for educational or professional purposes.
👨💻 Author: Thiago Vinhas
📅 Version: 1.0