Skip to content

thvinhas/Cipher-Decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🧩 Caesar Cipher Decoder (PHP)

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.


🧠 What is a Caesar Cipher?

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.


⚙️ Requirements

  • PHP 7.0+ installed on your system (macOS already includes PHP by default).
    You can check your version by running:
    php -v

📦 Installation

  1. Clone or download this project to your computer.

▶️ Usage

Option 1 — Run with custom arguments

You can pass the encoded text and shift value directly from the terminal.

php decoder.php "Mjqqt Btwqi" 5

Output:

Decoded text: Hello World

Option 2 — Run with no arguments

If no arguments are provided, the script runs a built-in example automatically:

php decoder.php

Output:

No arguments provided. Running example...

Encoded text: Aopz pz aol huzdly, dlss kvul!
Shift: 7

Decoded text: This is the answer, well done!

💡 How It Works

  • Each alphabetic character is shifted back by the given $shift value.
  • 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'.

🧩 Example Test Cases

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!

🧾 License

This project is open-source and free to use for educational or professional purposes.


👨‍💻 Author: Thiago Vinhas
📅 Version: 1.0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages