Ever wanted to add a layer of protection to your data without the complexity of modern cryptography? CaesarCipher.extended brings the classic Caesar cipher to Python, making it easy to obfuscate text, passwords, usernames, and more. It's not military-grade, but it's a huge step up from plain text!
The Caesar cipher is one of the oldest and simplest encryption techniques. Each character in your text is shifted by a fixed number of positions. This package extends the classic algorithm to support:
- Letters (upper & lower case)
- Digits (optional)
- Symbols (optional)
- Symbols
- Emojis (some support)
- Symbols
You choose what gets encrypted and how!
- Encrypt and decrypt text with a customizable shift
- Optionally include digits and symbols
- Input validation for safety
- Intuitive API for quick integration
- Perfect for small to mid-scale projects
- Much better than storing plain text
Install from PyPI:
pip install CaesarCipher.extendedOr clone from GitHub:
git clone https://github.com/ViratiAkiraNandhanReddy/CaesarCipher.extended.git
cd CaesarCipher.extendedfrom CaesarCipher import Encryption
# Basic encryption
enc = Encryption("Hello, World! 123")
print("Encrypted:", enc.encrypt())
# Advanced: shift everything
enc2 = Encryption("Secret123!π", shift = 7, alterNumbers = True, alterSymbols = True)
print("Encrypted:", enc2.encrypt())from CaesarCipher import Decryption
# Basic decryption
dec = Decryption("Olssv, Dvysk! 890", shift = 7, isNumbersAltered = True, isSymbolsAltered = True)
print("Decrypted:", dec.decrypt())You can encrypt or decrypt files in-place using encrypt_file() and
decrypt_file() on the corresponding class instances. Both methods read
the file contents, replace the file with the transformed text, and return
a boolean indicating success.
from CaesarCipher import Encryption, Decryption
# Encrypt a file in-place
enc = Encryption(shift = 4, alterNumbers = True, alterSymbols = True)
ok = enc.encrypt_file('secrets.txt')
if ok:
print('File encrypted')
# Decrypt a file in-place
dec = Decryption(shift = 4, isNumbersAltered = True, isSymbolsAltered = True)
ok = dec.decrypt_file('secrets.txt')
if ok:
print('File decrypted')Notes:
- These methods return
Falsewhen the file does not exist or when the process lacks permission to read/write the file. Other errors will propagate.
Encryption(text: str, shift: int = 3, alterSymbols: bool = False, alterNumbers: bool = False)text: The string to encryptshift: How many positions to shift (default: 3)alterSymbols: Shift symbols? (default: False)alterNumbers: Shift digits? (default: False)
Returns the encrypted string.
Decryption(text: str, shift: int = 3, isSymbolsAltered: bool = False, isNumbersAltered: bool = False)text: The string to decryptshift: How many positions to shift back (default: 3)isSymbolsAltered: Were symbols shifted? (default: False)isNumbersAltered: Were digits shifted? (default: False)
Returns the decrypted string.
See how CaesarCipher transforms your data:
| Stage | Example Text |
|---|---|
| Original | HelloWorld123! |
| After Encryption | KhoorZruog456! |
| After Decryption | HelloWorld123! |
How it works:
- Encryption shifts each character by a fixed amount (default: 3).
- Decryption reverses the shift, restoring the original text.
You can customize the shift and choose to include digits and symbols for even more flexibility!
- Not for high-security needs! Vulnerable to brute-force and frequency analysis.
- Symbol shifting may produce non-printable characters.
- For real password storage, use cryptographic hashes (bcrypt, Argon2, etc).
- Small to mid-scale projects
- Obfuscating sensitive data (usernames, passwords, tokens)
- Educational demos
- Quick protection for logs or configs
π― : Some encryption is always better than none. This package is a practical upgrade from plain text!
Β© 2025 ViratiAkiraNandhanReddy. This project is licensed under the GNU GENERAL PUBLIC LICENSE .
Developed by ViratiAkiraNandhanReddy
π€ - PASSIVE MAINTENANCE : Mean the project is no longer actively developed ( NO New Features And Regular Updates ), but the maintainer will respond only when an issue or PR is raised. Feel free to fork and continue development!