Compare.heading

并排比较23种古典密码。此参考表涵盖密码类型、密钥格式、安全级别、密钥空间大小和最佳使用场景,帮助您选择适合的密码。

Full Cipher Comparison

CipherTypeKey TypeKey SpaceSecurityYear
Caesar CipherMonoalphabetic SubstitutionSingle integer (1-25)25Very Weak~58 BC
ROT13Monoalphabetic SubstitutionFixed (shift of 13)1None (obfuscation only)1982
Atbash CipherMonoalphabetic SubstitutionNone (fixed mapping)1Very Weak~500 BC
Affine CipherMonoalphabetic SubstitutionTwo integers (a, b)312Weak~1900s
Keyword CipherMonoalphabetic SubstitutionKeyword string~2×10²⁶Weak~1500s
Pigpen CipherSymbol SubstitutionNone (fixed grid)1Very Weak~1700s
Polybius SquareFractionation5×5 grid arrangement~2×10²⁶Weak~150 BC
Vigenère CipherPolyalphabetic SubstitutionKeyword string26ⁿ (n = key length)Moderate1553
Beaufort CipherPolyalphabetic SubstitutionKeyword string26ⁿ (n = key length)Moderate~1857
Autokey CipherPolyalphabetic SubstitutionKeyword + plaintext extension26ⁿ (non-repeating key)Moderate-Strong1586
Trithemius CipherPolyalphabetic SubstitutionNone (auto-incrementing shift)1Weak1508
Gronsfeld CipherPolyalphabetic SubstitutionNumeric key (digits 0-9)10ⁿ (n = key length)Weak-Moderate~1700s
Porta CipherPolyalphabetic SubstitutionKeyword string (13 alphabets)13ⁿ (n = key length)Moderate1563
Running Key CipherPolyalphabetic SubstitutionBook/text passage (same length as message)Very large (full text)Moderate-Strong~1800s
Playfair CipherDigraph Substitution5×5 keyword matrix~2×10²⁶Moderate1854
Four-Square CipherDigraph SubstitutionTwo 5×5 keyword matrices(~2×10²⁶)²Strong (for classical)1902
Hill CipherPolygraphic SubstitutionN×N invertible matrixVery large (matrix dependent)Moderate-Strong1929
Alberti Disk CipherPolyalphabetic SubstitutionDisk position + shift scheduleVariable (depends on rotation frequency)Moderate1467
Baconian CipherBinary Encoding / SteganographyNone (fixed 5-bit encoding)1Weak (steganographic only)1605
Homophonic CipherHomophonic SubstitutionMultiple symbols per letterVery large (mapping dependent)Moderate-Strong~1400s
Morse CodeEncoding (not encryption)None (standard mapping)1None (encoding, not cipher)1837
Vernam Cipher (OTP)Stream CipherRandom key (same length as message)26ⁿ (truly random)Perfect (information-theoretically secure)1917
Straddling CheckerboardFractionationLetter arrangement + row headersVery largeModerate~1940s
Quagmire CipherPolyalphabetic Substitution1-3 keyword alphabets + indicatorVery large (multiple mixed alphabets)Strong (for classical)~1900s

Caesar vs ROT13 vs Atbash — Monoalphabetic Substitution Compared

Caesar, ROT13, and Atbash are the three simplest substitution ciphers. All three replace each letter with a fixed counterpart, but they differ in how the substitution alphabet is determined. The table below encrypts the same plaintext with each cipher so you can see the differences directly.

FeatureCaesar CipherROT13Atbash
Substitution RuleShift each letter forward by k positionsShift each letter forward by 13 positionsReverse the alphabet (A↔Z, B↔Y, ...)
KeyInteger 1-25 (variable)None (fixed at 13)None (fixed reversal)
Key Space2511
Self-Inverse?No (decrypt requires reverse shift)Yes (apply twice → original)Yes (apply twice → original)
"HELLO" encryptedKHOOR (shift 3)URYYBSVOOL
"ATTACK" encryptedDWWDFN (shift 3)NGGNPXZGGZXP
FormulaE(x) = (x + k) mod 26E(x) = (x + 13) mod 26E(x) = (25 − x) mod 26
Handles Numbers?Optional (with extended alphabet)No (letters only; use ROT5 for digits)No (letters only)
OriginJulius Caesar, ~58 BCUsenet forums, 1982Hebrew scholars, ~500 BC
Best Use CaseTeaching encryption fundamentalsHiding spoilers, casual obfuscationBiblical/historical study, puzzles

When should you use which?

  • Caesar — Use when teaching how substitution ciphers work. The variable key (1-25) demonstrates the concept of a secret parameter. It is the standard starting point for cryptography education.
  • ROT13 — Use when you need quick, reversible obfuscation without managing keys. Its self-inverse property (encode = decode) makes it ideal for hiding spoilers, puzzle answers, or content that should be readable only by intentional effort.
  • Atbash — Use for historical or literary contexts. Atbash appears in the Hebrew Bible (Jeremiah 25:26 encodes "Babylon" as "Sheshach") and is a natural choice for puzzles involving alphabet reversal.

Vigenère vs Beaufort vs Autokey — Polyalphabetic Substitution Compared

Vigenère, Beaufort, and Autokey are polyalphabetic ciphers that use a keyword to cycle through multiple substitution alphabets. They share the same core concept but differ in how they apply the keyword, whether the cipher is reciprocal, and how the key extends beyond its initial length.

FeatureVigenèreBeaufortAutokey
Encryption FormulaC = (P + K) mod 26C = (K − P) mod 26C = (P + Ki) mod 26
Key ExtensionKeyword repeats cyclicallyKeyword repeats cyclicallyKeyword + plaintext appended as key
Self-Reciprocal?No (decrypt subtracts key)Yes (same operation encrypts and decrypts)No (decrypt requires iterative key recovery)
Repeating Key Pattern?Yes — vulnerable to KasiskiYes — vulnerable to KasiskiNo — key is non-repeating
"HELLO" + key "KEY"RIJVSDSJJGRIJSS
"ATTACK" + key "KEY"KXDKEMKVFAOQKXDKEK
Key DerivationKEY→KEYKE→KEYKEY...KEY→KEYKE→KEYKEY...KEY→KEYHE→KEYHELLO...
Tabula RectaStandard (row = key, col = plain)Reversed (row = key, col = cipher)Standard (same as Vigenère)
Cracking MethodKasiski examination + frequency analysisSame as Vigenère (Kasiski + Friedman)Known-plaintext attack, statistical methods
Security LevelModerateModerateModerate-Strong
InventorGiovan Battista Bellaso (1553), attributed to VigenèreSir Francis Beaufort (~1857)Blaise de Vigenère (1586)

When should you use which?

  • Vigenère — The standard polyalphabetic cipher and the best starting point for learning multi-alphabet encryption. It was considered unbreakable for 300 years and remains the most widely taught cipher beyond Caesar. Use it for education, CTF challenges, and understanding how keyword-based encryption works.
  • Beaufort — Use when you need a reciprocal cipher (same operation for encrypt and decrypt) with polyalphabetic security. Beaufort simplifies implementation since you only need one function. It is particularly useful in field scenarios where operators should not need to remember separate encrypt/decrypt procedures.
  • Autokey — Use when you need stronger security than Vigenère without a more complex algorithm. By appending plaintext to the key, Autokey eliminates the repeating key pattern that makes Vigenère vulnerable to Kasiski examination. It is the strongest of the three for short messages.

How do classical ciphers compare in security?

Security levels range from "None" (no secret key, just encoding) to "Perfect" (mathematically unbreakable). Most classical ciphers fall between Very Weak and Moderate by modern standards.

Security LevelCiphersMain Vulnerability
PerfectVernam (One-Time Pad)None \u2014 unbreakable if used correctly
StrongFour-Square, Quagmire, HomophonicExtensive cryptanalysis, large known-plaintext needed
ModerateVigen\u00E8re, Beaufort, Autokey, Playfair, Hill, Porta, Running KeyKasiski examination, known-plaintext attacks, frequency analysis on pairs
WeakAffine, Keyword, Gronsfeld, Trithemius, PolybiusFrequency analysis, small key space, predictable patterns
Very Weak / NoneCaesar, ROT13, Atbash, Pigpen, Morse, BaconianBrute force (seconds), no secret key, known mapping

What are the main types of classical ciphers?

Classical ciphers fall into several categories based on how they transform plaintext. Understanding these categories helps in both selecting a cipher and knowing how to break one.

Cipher TypeHow It WorksExamplesKey Weakness
Monoalphabetic SubstitutionEach letter always maps to the same ciphertext letterCaesar, Atbash, Affine, KeywordPreserves letter frequency \u2014 easy to crack with frequency analysis
Polyalphabetic SubstitutionUses multiple alphabets, cycling based on a keywordVigen\u00E8re, Beaufort, Autokey, PortaKey repetition creates detectable patterns (Kasiski)
Digraph / PolygraphicEncrypts 2+ letters at a time as a unitPlayfair, Four-Square, HillDigraph frequency analysis (676 pairs vs 26 letters)
FractionationConverts letters to numbers/coordinates, then transformsPolybius, Straddling CheckerboardFrequency analysis on coordinate pairs
Stream CipherCombines plaintext with a key stream one character at a timeVernam (One-Time Pad)Key management \u2014 key must be truly random and never reused

When were classical ciphers invented?

Classical ciphers span over 2,500 years of cryptographic history, from ancient Hebrew scholars to 20th century military intelligence.

EraPeriodCiphers IntroducedKey Advance
Ancient500 BC \u2013 100 BCAtbash, Caesar, PolybiusFirst substitution and fractionation concepts
Renaissance1400s \u2013 1600sAlberti, Vigen\u00E8re, Porta, Trithemius, Autokey, BaconianPolyalphabetic substitution invented
Industrial1700s \u2013 1800sPlayfair, Beaufort, Pigpen, MorseDigraph encryption and practical field ciphers
Modern Classical1900s \u2013 1940sFour-Square, Hill, Vernam, Straddling CheckerboardMathematical foundations and provable security

Best Use Cases by Cipher

CipherBest ForHow It Is Cracked
Caesar CipherEducation, puzzles, ROT13Brute force, frequency analysis
ROT13Spoiler hiding, casual obfuscationApply ROT13 again (self-inverse)
Atbash CipherBiblical studies, simple encodingKnown pattern, frequency analysis
Affine CipherMath education, modular arithmeticBrute force (312 keys), frequency analysis
Keyword CipherMemorable key encryptionFrequency analysis
Pigpen CipherVisual encoding, children's gamesKnown symbol grid
Polybius SquareCoordinate-based encoding, telegraphyFrequency analysis on coordinate pairs
Vigenère CipherHistorical encryption, educationKasiski examination, Friedman test
Beaufort CipherReciprocal encryption (same operation encrypts/decrypts)Same as Vigenère (Kasiski, Friedman)
Autokey CipherImproved Vigenère without repeating keyKnown-plaintext attack, statistical methods
Trithemius CipherHistorical study, progressive shift conceptKnown pattern (predictable shifts)
Gronsfeld CipherNumeric-key variant of VigenèreSame as Vigenère with smaller key space
Porta CipherSelf-reciprocal polyalphabetic cipherFrequency analysis on half-alphabets
Running Key CipherLong-key encryption using existing textStatistical analysis, known-book attack
Playfair CipherMilitary field use, digraph encryptionDigraph frequency analysis
Four-Square CipherDual-key digraph encryptionExtensive digraph frequency analysis
Hill CipherMathematical/matrix-based encryptionKnown-plaintext attack with linear algebra
Alberti Disk CipherFirst polyalphabetic cipher, historical studyPattern analysis on rotation points
Baconian CipherHidden messages in plain text, steganographyPattern recognition on binary groups
Homophonic CipherDefeating frequency analysisStatistical analysis, hill climbing
Morse CodeTelegraph communication, emergency signals (SOS)Standard reference chart
Vernam Cipher (OTP)Provably unbreakable encryption when used correctlyUnbreakable if key is truly random, used once, kept secret
Straddling CheckerboardCompact encoding for spy communicationsFrequency analysis on variable-length codes
Quagmire CipherAdvanced polyalphabetic with mixed alphabetsExtensive cryptanalysis, pattern detection

Frequently Asked Questions

What is the difference between Caesar cipher and Vigenere cipher?

The Caesar cipher uses a single fixed shift value to replace each letter (monoalphabetic substitution), making it vulnerable to frequency analysis with only 25 possible keys. The Vigenere cipher uses a keyword to apply different shift values to each letter (polyalphabetic substitution), producing 26^n possible keys where n is the keyword length. This makes Vigenere significantly harder to crack, though it can be broken with the Kasiski examination or Friedman test.

Which classical cipher is the most secure?

The Vernam cipher (one-time pad) is the only classical cipher with mathematically proven perfect security — it is information-theoretically unbreakable when the key is truly random, at least as long as the message, used only once, and kept completely secret. Among practical classical ciphers, the Four-Square and Quagmire ciphers offer the strongest security due to their large key spaces and complex substitution patterns.

What is the difference between monoalphabetic and polyalphabetic ciphers?

Monoalphabetic ciphers (Caesar, Atbash, Affine, Keyword) use a single fixed substitution alphabet — each plaintext letter always maps to the same ciphertext letter. This preserves letter frequency patterns and makes them easy to crack. Polyalphabetic ciphers (Vigenere, Beaufort, Autokey, Porta) use multiple substitution alphabets, cycling through them based on a keyword. This flattens frequency distributions and makes cryptanalysis significantly harder.

Why is ROT13 not considered encryption?

ROT13 is technically a Caesar cipher with a fixed shift of 13, but it has no secret key — everyone knows the transformation. It provides zero security since anyone can decode it instantly. ROT13 is used purely for obfuscation, such as hiding spoilers or puzzle answers online. Its unique property is that applying ROT13 twice returns the original text (self-inverse), making it convenient for casual use.

How do digraph ciphers like Playfair differ from single-letter ciphers?

Single-letter ciphers (Caesar, Vigenere) encrypt one letter at a time, while digraph ciphers (Playfair, Four-Square) encrypt two letters simultaneously as a pair. This breaks up common single-letter frequency patterns and creates 676 possible digraph substitutions instead of 26 single-letter ones. Digraph ciphers are harder to crack because frequency analysis must operate on 676 pairs rather than 26 individual letters.

What is the difference between Caesar, ROT13, and Atbash?

All three are monoalphabetic substitution ciphers that replace each letter with a fixed counterpart. Caesar shifts each letter forward by a chosen number (1–25), giving it 25 possible keys. ROT13 is a Caesar cipher locked at shift 13 — it has no key and is self-inverse (applying it twice returns the original). Atbash reverses the alphabet (A↔Z, B↔Y) — it also has no key and is self-inverse. Caesar is used for teaching, ROT13 for casual obfuscation, and Atbash appears in biblical and historical contexts.

What is the difference between Vigenère, Beaufort, and Autokey ciphers?

All three are polyalphabetic substitution ciphers that use a keyword to apply different shifts to each letter. Vigenère adds the key letter to the plaintext letter (C = P + K mod 26) and repeats the keyword cyclically. Beaufort subtracts the plaintext from the key (C = K − P mod 26), making it self-reciprocal — the same operation encrypts and decrypts. Autokey starts with the keyword but then appends the plaintext itself as additional key material, eliminating the repeating key pattern that makes Vigenère vulnerable to Kasiski examination. Autokey is the most secure of the three.