About this tool
The Caesar Cipher is one of the earliest recorded symmetric substitution cryptosystems, used by Julius Caesar to safeguard tactical battle orders. Its algorithm shifts each plaintext letter forward or backward along the alphabet by a fixed integer key (1–25). In modern hacker culture and web forums, shift 13—known as **ROT13**—is widely employed to conceal film spoilers and puzzle clues because the 26-letter Latin alphabet makes it self-reciprocal (re-encrypting decrypts the text). This tool provides client-side Caesar shifting, instant ROT13 toggling, and complete 25-key brute-force decryption.
How to Use This Tool (Step-by-Step)
Enter Text or Ciphertext
Type your English message, puzzle riddle, or intercepted classical ciphertext into the input window.
Set Shift Offset or Toggle ROT13
Slide the key selector (1–25 shifts), or click the 'ROT13' quick preset button for standard 13-letter symmetric rotation.
Inspect Ciphertext & Brute Force
The ciphertext updates in real time. Use 'Brute Force Table' to display all 25 shift permutations simultaneously to crack unknown keys.
Modular Arithmetic Mod 26 Engine
Computes cyclic shifts via `(char + shift) % 26`, preserving original uppercase/lowercase cases while leaving punctuation intact.
Instant Invertible ROT13 Mode
Leverages the reciprocal property of ROT13 (`13 + 13 = 26`): running the exact same transform twice decrypts back to plaintext.
100% Client-Side Air-Gapped
Cipher shifts execute entirely inside local browser memory. Puzzle solutions and game riddles remain 100% confidential.
Cryptanalysis Gotchas & Caesar Cipher Tips
- •Never use Caesar for real security: With only 25 possible keys, computers brute-force the entire keyspace in microseconds. Use AES.
- •Crack Caesar via frequency analysis: The most frequent letter in the ciphertext almost always corresponds to 'E'. Subtracting ASCII offsets instantly reveals the key.
- •Spoiler protection etiquette: Online discussion boards use ROT13 as a polite obfuscation layer, allowing users to opt into reading plot spoilers.
Code & Transformation Examples
Caesar Shift 3 vs ROT13 Benchmark
HELLO WORLD (世界你好)• 经典凯撒位移 (Shift = 3) : KHOOR ZRUOG
(A->D, B->E, H->K, E->H, L->O...)
• 极客经典 ROT13 (Shift = 13): URYYB JBEYQ
(A->N, B->O, H->U, E->R, L->Y...)* Applying ROT13 onto `URYYB JBEYQ` inverts it mathematically straight back to `HELLO WORLD`.
JavaScript Caesar Cipher Implementation Snippet
function caesarCipher(str, shift = 13) {
const s = ((shift % 26) + 26) % 26; // 处理负数偏移
return str.replace(/[a-zA-Z]/g, c => {
const base = c <= 'Z' ? 65 : 97;
return String.fromCharCode(((c.charCodeAt(0) - base + s) % 26) + base);
});
}const cipher = caesarCipher("Secret Message", 13);
console.log(cipher); // "Frperg Zrffntr"
console.log(caesarCipher(cipher, 13)); // "Secret Message" (自逆解密!)* Matching letters via regex leaves spaces, numbers, and emojis untouched in their natural positions.
Frequently Asked Questions
Q: Why is ROT13 encryption and decryption completely identical?
A: Because 13 is half of 26. Rotating a character by 13 twice equals rotating 26 places, which wraps completely around the modular clock back to start.
Q: Does the Caesar cipher shift Chinese characters or digits?
A: Classical Caesar ciphers operate strictly across Latin A-Z letters. Numbers, Chinese characters, and punctuation pass through unchanged.
Q: Can shift keys be negative (e.g., -3 shifts left)?
A: Yes. In modular arithmetic, shifting left by 3 (-3) is identical to shifting right by 23 (`26 - 3 = 23`). Negative offsets are fully supported.