Encryption Calculator

Encrypt and decrypt text using various classical ciphers like Caesar, Vigenere, and more.

Select Cipher

Plain Text

Encrypted Text

Khoor Zruog

Note: These are classical ciphers for educational purposes. For real security, use modern encryption algorithms like AES.

What Is Encryption and Why Does It Matter?

Encryption is the process of transforming readable information — called plaintext — into an unreadable scrambled form called ciphertext, using a mathematical algorithm and, in most cases, a key. Only someone who possesses the correct key and algorithm can reverse the process and recover the original message. Encryption is one of the oldest and most fundamental practices in information security, with roots stretching back thousands of years to ancient Egypt, Rome, and the Arab world.

In everyday digital life, encryption protects your banking sessions, private messages, passwords, and healthcare records from eavesdroppers and attackers. Every time you see "https://" in your browser's address bar, a modern encryption protocol (TLS) is keeping your data private in transit. Every time you log in with a password, that password is (or should be) stored as a cryptographic hash — a one-way transformation that prevents the raw password from ever being saved in plaintext.

Understanding the principles behind encryption is valuable for developers, security students, and curious learners alike. This encryption calculator exposes several classical cipher algorithms — Caesar, Vigenere, ROT13, Atbash, XOR, Morse code, binary, and reverse — in an interactive tool that lets you experiment with encryption and decryption instantly. While these classical ciphers are not secure by modern standards, studying them builds intuition for how substitution, transposition, and key-based transformations work, which are the same conceptual building blocks found in AES, RSA, and other modern algorithms.

Encryption differs from encoding and hashing in important ways. Encoding (such as Base64 or URL encoding) transforms data into a different format for compatibility — it is reversible without any key. Hashing (such as SHA-256 or MD5) is a one-way function with no intended reversal. Encryption is specifically designed to be reversible, but only by an authorized party who holds the decryption key. This encryption calculator supports both encrypt and decrypt operations for all supported ciphers, making it easy to observe the full round-trip transformation.

Cipher Algorithms: How Each One Works

This encryption calculator supports eight distinct cipher algorithms. Each one uses a different mathematical transformation. Understanding the mechanism behind each cipher helps you choose the right one for educational demonstrations and puzzle-solving.

Caesar Cipher

The Caesar cipher shifts every alphabetic character forward (for encryption) or backward (for decryption) by a fixed number of positions in the alphabet, wrapping around from Z back to A. The shift amount is the key. For example, with a shift of 3, the letter "A" becomes "D", "B" becomes "E", and "Z" becomes "C". Non-alphabetic characters (digits, spaces, punctuation) pass through unchanged.

ROT13

ROT13 is a special case of the Caesar cipher with a fixed shift of 13. Because the English alphabet has 26 letters and 13 is exactly half of 26, applying ROT13 twice always restores the original text. This means the encrypt and decrypt operations are identical — you simply apply ROT13 again to undo it. ROT13 is commonly used to hide spoilers and puzzle answers in online forums.

Atbash

Atbash is an ancient Hebrew cipher that maps each letter to its mirror-image position in the alphabet: A becomes Z, B becomes Y, C becomes X, and so on. Like ROT13, it is its own inverse — applying Atbash twice returns the original text. The name comes from the Hebrew letters Aleph-Tav-Beth-Shin, reflecting the A→Z and B→Y substitutions.

Vigenere Cipher

The Vigenere cipher is a polyalphabetic substitution cipher that uses a keyword rather than a single shift value. The keyword is repeated to match the length of the plaintext. Each alphabetic character in the plaintext is shifted by the alphabetic position of the corresponding keyword character (A=0, B=1, …, Z=25). Because different characters are shifted by different amounts, the Vigenere cipher resists simple frequency analysis that defeats the Caesar cipher.

XOR Cipher

The XOR cipher applies a bitwise exclusive-OR operation between each character's ASCII code and a numeric key (0–255). XOR encryption is symmetric: applying the same XOR key a second time restores the original value. While not cryptographically secure on its own, XOR is a core building block in stream ciphers and block cipher modes such as CTR and CFB.

Morse Code, Binary, and Reverse

Morse code encodes each letter and digit as a sequence of dots and dashes. Binary encoding represents each character as its 8-bit ASCII binary code, separated by spaces. Reverse simply mirrors the entire input string. These three transformations are technically encodings rather than ciphers, but they are included as useful educational demonstrations of character-level transformations.

Encryption Formulas

Caesar: C = (P - base + shift + 26) % 26 + base | Vigenere: C = (P - base + K_i + 26) % 26 + base | XOR: C = P ^ keyCode | Atbash: C = base + 25 - (P - base) | Binary: C = charCodeAt(0).toString(2).padStart(8,"0")

Where:

  • P= Character code point of the plaintext letter (charCodeAt(0))
  • C= Character code point of the ciphertext letter
  • base= 65 for uppercase letters (A–Z), 97 for lowercase letters (a–z)
  • shift= Caesar cipher shift amount (positive for encrypt, negative for decrypt)
  • K_i= Vigenere key character value at position i: keyChar.charCodeAt(0) - 65
  • keyCode= XOR numeric key (0–255); applied as char.charCodeAt(0) ^ keyCode
  • % 26= Modulo 26 wraps the shifted value back within the 26-letter alphabet

The Caesar Cipher: History and Mathematics

The Caesar cipher is one of the earliest known substitution ciphers, named after Julius Caesar who reportedly used a shift of 3 to protect military communications around 58 BCE. Despite its extreme simplicity by modern standards, it illustrates every essential concept of symmetric encryption: a plaintext input, a key (the shift value), a deterministic transformation, and an inverse transformation (decryption) that recovers the original message.

The mathematical formula for Caesar encryption is straightforward. For each alphabetic character, compute its zero-based position in the alphabet (so A=0, B=1, …, Z=25), add the shift value, take the result modulo 26 to wrap around the end of the alphabet, then convert back to a character. For decryption, subtract the shift instead of adding it — or equivalently, add (26 - shift) % 26 to keep the arithmetic positive before applying modulo 26.

The code in this calculator uses the formula ((char.charCodeAt(0) - base + actualShift + 26) % 26) + base, where base is 65 for uppercase letters and 97 for lowercase letters. Adding 26 before the modulo operation ensures the result is never negative even when the shift is negative (during decryption), which is a common implementation guard in modular arithmetic.

The Caesar cipher is trivially broken by brute force: there are only 25 possible non-trivial shift values, so an attacker can try all of them in seconds and identify the correct one by checking which result produces readable English. This is why frequency analysis and brute-force attacks are so effective against it. Understanding the Caesar cipher's weaknesses directly motivates the design of stronger ciphers such as Vigenere (which uses a multi-character key to vary the shift) and ultimately modern block ciphers (which use much larger key spaces and non-linear substitution).

Plain (shift=3) A B C X Y Z
Cipher D E F A B C

The table above illustrates the wrap-around behavior: X (position 23) shifts to A (position 0), Y shifts to B, and Z shifts to C. This wrapping is handled by the % 26 modulo operation in the formula.

Vigenere and XOR Ciphers: Key-Based Encryption

The Vigenere cipher was considered unbreakable for nearly three centuries after its introduction in the 16th century — earning it the nickname "le chiffre indéchiffrable" (the indecipherable cipher). Its strength over the Caesar cipher comes from using a multi-character keyword that changes the shift amount for each position in the plaintext, defeating simple frequency analysis.

The Vigenere algorithm works as follows. The keyword is converted to uppercase and any non-alphabetic characters are removed. It is then repeated cyclically to match the length of the plaintext. For each alphabetic character at position i in the plaintext, the shift is the alphabetic index of the corresponding keyword character (A=0, B=1, …, Z=25). The formula is identical to Caesar but uses a position-specific shift value: C = ((P - base + K_i + 26) % 26) + base. Decryption subtracts K_i instead.

For example, encrypting "HELLO" with keyword "KEY" proceeds as follows. The keyword cycles as K-E-Y-K-E (positions 10, 4, 24, 10, 4). "H" (position 7) shifts by 10 to "R"; "E" (4) shifts by 4 to "I"; "L" (11) shifts by 24 to "J"; "L" (11) shifts by 10 to "V"; "O" (14) shifts by 4 to "S". The encrypted result is "RIJVS".

The XOR cipher operates at the byte level rather than the alphabet level. For each character, the calculator computes char.charCodeAt(0) ^ keyCode, where ^ is the bitwise XOR operator and keyCode is a numeric key from 0 to 255. XOR has the self-inverse property: (A ^ K) ^ K = A for any values A and K. This means the exact same operation encrypts and decrypts the data — you simply apply XOR with the same key again. This symmetric property makes XOR extremely efficient and is why it appears in virtually every modern stream cipher and is used in building block cipher modes like CTR and OFB.

Note that a single-byte XOR key is not cryptographically secure: an attacker who knows or guesses even a few characters of plaintext can immediately recover the key by XOR-ing the known plaintext with the corresponding ciphertext bytes. Multi-byte or key-stream XOR (as used in one-time pads and stream ciphers) is much stronger but requires proper key management to be secure.

Use Cases for Classical Cipher Encryption

While classical ciphers are not suitable for protecting sensitive data against modern attackers, they have a wide range of legitimate and practical applications in education, games, puzzles, and low-stakes obfuscation. Understanding where and why to use this encrypt and decrypt text calculator helps you get the most value from it.

  • Computer science and cryptography education: Teachers and students use Caesar, Vigenere, and Atbash ciphers to illustrate core cryptographic concepts — substitution, transposition, key spaces, and frequency analysis — before moving on to modern algorithms like AES and RSA. This calculator makes it easy to demonstrate these concepts interactively in a classroom or self-study setting.
  • Puzzle design and escape rooms: Game designers use ROT13, Atbash, Caesar, and Morse code as puzzle elements in escape rooms, treasure hunts, ARGs (alternate reality games), and online puzzle competitions. These ciphers are well-known enough that solvers can recognize and decode them with the right hint, but obscure enough to provide a satisfying challenge for beginners.
  • Capture the Flag (CTF) competitions: CTF security competitions frequently include challenges where participants must decrypt messages encoded with classical ciphers. Having a reliable online encryption calculator that handles multiple cipher types in one tool speeds up the solving process significantly.
  • Spoiler and content hiding: ROT13 is traditionally used in online forums (especially Reddit and Usenet) to hide spoilers, offensive jokes, or puzzle answers. Readers who want to see the content can easily decode it, while those who want to avoid it simply skip the ROT13 text.
  • Morse code communication: Morse code was the dominant long-distance communication standard from the 1840s through the mid-20th century. It remains relevant in amateur (ham) radio, aviation, and as an accessibility input method. The Morse code mode in this calculator converts text to standard International Morse Code and back.
  • Learning bitwise operations: The XOR cipher is an excellent hands-on way to understand how bitwise XOR works on character data, which is a prerequisite for understanding stream ciphers, one-time pads, and the XOR-based mixing steps inside modern hash functions and block ciphers.

For any application where real security is required — protecting passwords, financial data, private messages, or personal health information — you should use modern, peer-reviewed cryptographic algorithms and libraries such as AES-256-GCM, ChaCha20-Poly1305, or RSA-OAEP, implemented through trusted libraries like the Web Crypto API, libsodium, or OpenSSL. The classical ciphers in this tool are purely educational.

Worked Examples

Caesar Cipher Encryption (Shift = 3)

Problem:

Encrypt the word "HELLO" using the Caesar cipher with a shift of 3.

Solution Steps:

  1. 1H: base=65, code=72, (72 - 65 + 3 + 26) % 26 + 65 = 36 % 26 + 65 = 10 + 65 = 75 → K
  2. 2E: code=69, (69 - 65 + 3 + 26) % 26 + 65 = 33 % 26 + 65 = 7 + 65 = 72 → H
  3. 3L: code=76, (76 - 65 + 3 + 26) % 26 + 65 = 40 % 26 + 65 = 14 + 65 = 79 → O
  4. 4L: same as above → O
  5. 5O: code=79, (79 - 65 + 3 + 26) % 26 + 65 = 43 % 26 + 65 = 17 + 65 = 82 → R
  6. 6Concatenate results: "KHOOR"

Result:

KHOOR

Vigenere Cipher Encryption (Keyword = "KEY")

Problem:

Encrypt "HELLO" with the Vigenere cipher using the keyword "KEY".

Solution Steps:

  1. 1Key cycles as K(10), E(4), Y(24), K(10), E(4) for positions 0–4
  2. 2H(7) + K(10) = 17 → R
  3. 3E(4) + E(4) = 8 → I
  4. 4L(11) + Y(24) = 35 % 26 = 9 → J
  5. 5L(11) + K(10) = 21 → V
  6. 6O(14) + E(4) = 18 → S
  7. 7Concatenate: "RIJVS"

Result:

RIJVS

XOR Cipher Encryption (Key = 42)

Problem:

Encrypt the letter "A" using the XOR cipher with key 42.

Solution Steps:

  1. 1"A" has ASCII code 65
  2. 2Key is 42 (decimal), which is 00101010 in binary
  3. 365 in binary is 01000001
  4. 4XOR: 01000001 ^ 00101010 = 01101011 = 107 decimal
  5. 5String.fromCharCode(107) = "k"
  6. 6Decryption check: "k" XOR 42 → 107 ^ 42 = 65 → "A" ✓

Result:

"k" (ASCII 107)

ROT13 Encoding

Problem:

Apply ROT13 to the word "Secret".

Solution Steps:

  1. 1ROT13 is a Caesar cipher with a fixed shift of 13
  2. 2S(18) + 13 = 31 % 26 = 5 → F
  3. 3e(4) + 13 = 17 → r
  4. 4c(2) + 13 = 15 → p
  5. 5r(17) + 13 = 30 % 26 = 4 → e
  6. 6e(4) + 13 = 17 → r
  7. 7t(19) + 13 = 32 % 26 = 6 → g
  8. 8Result: "Frperg"; applying ROT13 again returns "Secret" ✓

Result:

Frperg

Tips & Best Practices

  • Use Caesar cipher shift=13 for ROT13 behavior — both produce the same result, and applying either one twice restores the original text.
  • For Vigenere, longer and more random-looking keywords produce harder-to-crack ciphertext; short dictionary words (like "cat" or "key") are much weaker.
  • The XOR cipher is its own inverse — paste the ciphertext output back into the input with the same key to decrypt it in any mode.
  • When decrypting Vigenere, make sure your keyword contains only letters; the calculator strips all non-alphabetic characters from the keyword automatically.
  • Atbash and Reverse have no key — they are symmetric encodings, so the same button press (encrypt or decrypt) gives the same result.
  • For Morse code decryption, separate each letter code with a single space and separate words with a forward slash (/). Malformed input may produce unexpected characters.
  • The binary mode encodes each character as an 8-bit zero-padded ASCII code — useful for visualizing how text is stored at the byte level.
  • XOR key 0 returns the original text unchanged; key 255 flips every bit in every character — a useful sanity check when exploring XOR behavior.

Frequently Asked Questions

Encryption uses a key and a mathematical algorithm to transform data into ciphertext that can only be reversed by someone with the correct key. Encoding (such as Base64 or Morse code) transforms data into a different representation format for compatibility or transmission purposes, without any secret key — anyone who knows the encoding scheme can reverse it. The ciphers in this calculator that use a key (Caesar, Vigenere, XOR) are true encryption; the keyless ones (ROT13, Atbash, Morse code, binary, reverse) are technically encodings.
No. All classical ciphers supported in this tool are broken by modern cryptanalysis standards. The Caesar and ROT13 ciphers have tiny key spaces that are trivially brute-forced. Vigenere is vulnerable to the Kasiski test and index-of-coincidence analysis once the key length is determined. XOR with a short key is broken by known-plaintext attacks. For any real security need — passwords, financial data, private messages — you must use modern algorithms like AES-256, ChaCha20, or RSA, implemented via trusted libraries such as the Web Crypto API or libsodium.
Adding 26 before applying modulo 26 ensures the arithmetic result is never negative. During decryption, the shift is subtracted from the character position. For a character near the beginning of the alphabet (like "A" at position 0) with a large shift (like 20), the subtraction produces a negative value such as -20. Without the +26 guard, the modulo operation in JavaScript would return a negative number (-20 % 26 = -20), which would map to an invalid character code. Adding 26 lifts all possible results into the non-negative range before the modulo is applied.
The Vigenere key is repeated cyclically to match the length of the plaintext. The calculator strips any non-alphabetic characters from the key and converts it to uppercase, then accesses characters using the expression <code>keyUpper[keyIndex % keyUpper.length]</code>, where keyIndex increments for every alphabetic character in the plaintext. If the keyword is "KEY" (3 characters) and the plaintext has 10 alphabetic characters, the key sequence used is K-E-Y-K-E-Y-K-E-Y-K. Non-alphabetic characters in the plaintext (spaces, digits, punctuation) pass through unchanged and do not advance the key index.
A cipher is self-inverse when applying the same operation twice restores the original plaintext — in other words, the encrypt and decrypt functions are identical. ROT13, Atbash, XOR (with the same key), and the Reverse cipher all have this property. For ROT13 this works because shifting by 13 twice equals a total shift of 26, which is the same as no shift at all modulo 26. For Atbash it works because the mirror-image mapping is symmetric. For XOR it works because A XOR K XOR K = A for any values A and K.
In encrypt mode, the calculator converts each uppercase letter and digit to its standard International Morse Code symbol (dots and dashes) and joins the symbols with spaces, using a forward slash "/" for word spaces. In decrypt mode, the input is split by spaces, and each code is looked up in a reverse mapping (dots-and-dashes to character) to reconstruct the original text. The Morse code table covers all 26 letters (A–Z) and digits 0–9.
The Caesar and Vigenere cipher implementations use a regular expression <code>/[a-zA-Z]/g</code> that matches only alphabetic characters. Only matched characters are transformed; all other characters (spaces, digits, punctuation, special symbols) are returned as-is by the <code>replace</code> callback. This is the classical convention for these ciphers: numbers and punctuation are not part of the traditional alphabetic substitution alphabet, so they are left unchanged to preserve the structure of the message.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the Encryption Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.