Caesar Cipher

Nerd Cafe | نرد کافه

What is Caesar Cipher?

  • One of the simplest and oldest encryption techniques

  • Type of substitution cipher where each letter is shifted by a fixed number

  • Named after Julius Caesar who used it for military communications

  • Also known as shift cipher or Caesar shift

Caesar Cipher Alphabet Example

  • Shift = 3

Plain :  a  b  c  d  e
Cipher:  d  e  f  g  h
  • Example:

HELLO → KHOOR

Mathematical Representation:

  • Encryption:

E(x) = (x + k) mod 26
  • Decryption:

D(x) = (x - k) mod 26
  • Where x is letter position

Weaknesses:

  • Only 25 possible keys (shifts 1-25)

  • Extremely vulnerable to brute force attacks

  • Frequency analysis can easily break it

  • Not suitable for modern secure communications

Python Implementation

1. Encryption Function

2. Decryption Function

Practical Examples

Example 1: Basic Encryption & Decryption

Example 2: ROT13 (Very Common Variant)

💖 Support Our Work

If you find this post helpful and would like to support my work, you can send a donation via TRC-20 (USDT). Your contributions help us keep creating and sharing more valuable content.

circle-check

Thank you for your generosity! 🙏

Keywords

Caesar Cipher, shift cipher, substitution cipher, ROT13, encryption, decryption, modular arithmetic, brute force, frequency analysis, cryptography, classical cipher, Julius Caesar, monoalphabetic, wrap around, key space, ord chr, Python cipher, cipher text, plain text, crypto basics, nerd cafe , نرد کافه

Channel Overview

🌐 Website: www.nerd-cafe.irarrow-up-right

📺 YouTube: @nerd-cafearrow-up-right

🎥 Aparat: nerd_cafearrow-up-right

📌 Pinterest: nerd_cafearrow-up-right

📱 Telegram: @nerd_cafearrow-up-right

📝 Blog: Nerd Café on Virgoolarrow-up-right

💻 GitHub: nerd-cafearrow-up-right

Last updated