<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kevin</title>
    <description>The latest articles on DEV Community by Kevin (@kevingu).</description>
    <link>https://dev.to/kevingu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1381700%2F97f955aa-e099-427b-a362-18c4ebe47b90.png</url>
      <title>DEV Community: Kevin</title>
      <link>https://dev.to/kevingu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevingu"/>
    <language>en</language>
    <item>
      <title>How to Recognize a Classical Cipher Before Trying to Decode It</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Wed, 14 Oct 2026 05:41:51 +0000</pubDate>
      <link>https://dev.to/kevingu/how-to-recognize-a-classical-cipher-before-trying-to-decode-it-2pei</link>
      <guid>https://dev.to/kevingu/how-to-recognize-a-classical-cipher-before-trying-to-decode-it-2pei</guid>
      <description>&lt;p&gt;A puzzle gives you this message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IYPUN AOL NYLLU JHYK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You could paste it into every decoder you find. A better starting point is to ask what the text preserves, which simple hypotheses you can test, and what would count as evidence that one worked.&lt;/p&gt;

&lt;p&gt;This walkthrough uses three deliberately constructed examples. Their answers are known, so you can check the method without having to trust a tool's guess. Real messages usually offer less certainty.&lt;/p&gt;

&lt;p&gt;Disclosure: I maintain CaesarCipher.org, which provides the two tools linked below. These examples explain historical ciphers for puzzles and learning. Classical ciphers are unsuitable for protecting sensitive information.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Record the context before changing the text
&lt;/h2&gt;

&lt;p&gt;Keep a copy of the original, including spaces, punctuation, capitalization, and line breaks. They might be clues, or formatting added by the puzzle author. Removing them immediately can erase useful information.&lt;/p&gt;

&lt;p&gt;Write down the expected language, where the message appeared, any nearby images or instructions, and whether a key was supplied. A railway-themed puzzle might include a station name as a keyword. That is a hypothesis to test, not proof.&lt;/p&gt;

&lt;p&gt;Also question the premise: a short string might be an identifier, compressed data, or an encoding rather than a classical cipher. “Unreadable” does not tell you how a message was produced.&lt;/p&gt;

&lt;p&gt;For the opening example, assume the puzzle expects English and says only “bring something.” That gives us a small amount of context without revealing a key.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Inspect what survives
&lt;/h2&gt;

&lt;p&gt;Our message uses ordinary uppercase letters and contains words of five, three, five, and four letters. The third word contains a doubled letter: &lt;code&gt;NYLLU&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A substitution that consistently replaces each letter preserves repeated-letter patterns. A Caesar shift does this, as does Atbash and a general monoalphabetic substitution. None of those features distinguishes the three by itself.&lt;/p&gt;

&lt;p&gt;Digits, unusual symbols, and fixed-size groups would suggest other possibilities, but do not treat a visual resemblance as a diagnosis. A message written with symbols could be a substitution; a message written with letters could conceal several layers.&lt;/p&gt;

&lt;p&gt;Your first notes should be observations, such as “spaces present” or “double L,” rather than conclusions such as “definitely Caesar.”&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Test the cheap hypotheses
&lt;/h2&gt;

&lt;p&gt;A Caesar cipher shifts every letter by the same amount, wrapping around the alphabet. Here, encryption with a shift of seven maps &lt;code&gt;A&lt;/code&gt; to &lt;code&gt;H&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; to &lt;code&gt;I&lt;/code&gt;, and &lt;code&gt;Z&lt;/code&gt; to &lt;code&gt;G&lt;/code&gt;. Decryption reverses that shift.&lt;/p&gt;

&lt;p&gt;Try subtracting seven from each ciphertext letter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ciphertext: IYPUN AOL NYLLU JHYK
Plaintext:  BRING THE GREEN CARD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, &lt;code&gt;I → B&lt;/code&gt;, &lt;code&gt;Y → R&lt;/code&gt;, and &lt;code&gt;P → I&lt;/code&gt;. The complete sentence fits the supplied hint, and encrypting it again with +7 reproduces the original exactly.&lt;/p&gt;

&lt;p&gt;Without the shift, inspect all 26 possibilities, including the unchanged text. Software can list them quickly; your job is to decide whether a candidate is coherent and consistent with the context. A readable fragment alone is weaker evidence than a whole sentence that makes sense.&lt;/p&gt;

&lt;p&gt;This example has a verified answer because we constructed it. With an unknown message, a plausible reading remains a hypothesis until the surrounding puzzle supports it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Use frequencies to propose mappings
&lt;/h2&gt;

&lt;p&gt;Now consider a longer message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ZG GSV LOW HGZGRLM, XSVXP GSV HNZOO NZK.
GSV MLIGS TZGV LKVMH ZG MRMV.
PVVK GSV YOFV GLPVM FMGRO GSV URMZO ILLN,
GSVM GIZWV RG ULI Z KZKVI XOFV.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It contains 111 letters when spaces and punctuation are excluded. Its four most frequent letters are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ciphertext letter&lt;/th&gt;
&lt;th&gt;Count&lt;/th&gt;
&lt;th&gt;Percentage of letters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;V&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;15.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;G&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;14.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Z&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;9.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;8.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can reproduce the counts with the &lt;a href="https://caesarcipher.org/ciphers/frequency-analysis" rel="noopener noreferrer"&gt;letter-frequency analysis tool&lt;/a&gt;. Count only A–Z for this example; including punctuation in the denominator would give different percentages.&lt;/p&gt;

&lt;p&gt;In ordinary English, E is often frequent. That makes &lt;code&gt;V → E&lt;/code&gt; worth testing. It does not establish the mapping. The repeated three-letter word &lt;code&gt;GSV&lt;/code&gt;, appearing five times, supplies another clue. If it were THE, the proposed mapping would be &lt;code&gt;G → T&lt;/code&gt;, &lt;code&gt;S → H&lt;/code&gt;, and &lt;code&gt;V → E&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Those pairs fit Atbash, which reverses the alphabet: &lt;code&gt;A ↔ Z&lt;/code&gt;, &lt;code&gt;B ↔ Y&lt;/code&gt;, and so on. Apply the same mapping to the entire message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT THE OLD STATION, CHECK THE SMALL MAP.
THE NORTH GATE OPENS AT NINE.
KEEP THE BLUE TOKEN UNTIL THE FINAL ROOM,
THEN TRADE IT FOR A PAPER CLUE.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every letter follows one consistent rule. Applying Atbash again returns the ciphertext. That whole-message check is much stronger than guessing THE correctly once.&lt;/p&gt;

&lt;p&gt;Even 111 letters are a small, deliberately worded sample. Frequency rankings depend on vocabulary and topic. In &lt;code&gt;NIGHT&lt;/code&gt;, every letter occurs once and E never appears. There is no dependable “most common letter must be E” shortcut for short text.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Know what a repeating keyword changes
&lt;/h2&gt;

&lt;p&gt;Vigenère uses a repeating key to change the shift from letter to letter. In this example, use the standard A=0 through Z=25 convention, repeat &lt;code&gt;MAP&lt;/code&gt;, and advance the key only for letters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Plaintext:  MEET AT THE OLD CLOCK
Key stream: MAPM AP MAP MAP MAPMA
Ciphertext: YETF AI FHT ALS OLDOK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first M is shifted by the key letter M, or 12 positions, producing Y. The following E uses A, a zero shift, so it stays E. Spaces remain in place and do not consume key letters. Decryption subtracts the corresponding shifts and recovers the plaintext.&lt;/p&gt;

&lt;p&gt;A tool that advances the key across spaces uses a different convention and will produce a different result. Check the convention before declaring that the key is wrong.&lt;/p&gt;

&lt;p&gt;No supplied keyword does not rule out Vigenère. It means recovery is a harder problem. Repeated sequences and statistical methods can suggest key lengths in sufficiently informative text, but this 17-letter example offers little evidence for reliable unknown-key recovery. Do not promise to extract a unique key from it.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Treat identification as a shortlist
&lt;/h2&gt;

&lt;p&gt;An identifier is useful when the obvious checks fail. Try the &lt;a href="https://caesarcipher.org/ciphers/identifier" rel="noopener noreferrer"&gt;cipher identifier&lt;/a&gt;, then compare its candidates with your observations and test the proposed methods.&lt;/p&gt;

&lt;p&gt;For a reproducible exercise, use the opening Caesar ciphertext. Its construction is known to use +7; whatever candidates an identifier returns, that independent fact gives you a way to evaluate the suggestion. This article does not claim that the tool always ranks Caesar first.&lt;/p&gt;

&lt;p&gt;Short text, unusual language, missing spaces, and multiple layers can make candidates ambiguous. A label or confidence score is not a recovered plaintext and should not be treated as proof.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Leave a useful trail
&lt;/h2&gt;

&lt;p&gt;Keep a compact record: original message, expected language, preserved patterns, method, key convention, result, and reason for retaining or rejecting the hypothesis.&lt;/p&gt;

&lt;p&gt;When asking others for help, share that record and say whether you want hints or a full solution. Good codebreaking starts with inspectable evidence. A decoder becomes useful when you can explain why its result fits the message.&lt;/p&gt;

&lt;p&gt;Writing disclosure: This tutorial was generated with AI. Its worked examples, letter counts, and percentages were verified by computation.&lt;/p&gt;

</description>
      <category>cryptography</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
