# How would cryptographers break this type of code?

**URL:** <https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811>\
**Category:** Factual Questions\
**Created:** [November 4, 2021, 8:09pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811 "2021-11-04T20:09:14Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [November 5, 2021, 7:50pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/21 "2021-11-05T19:50:58Z")

</div>

Yeah, what I’m thinking is that this is essentially just a simple vigenere rotation cipher with a long keytext that you can work both on the cipher text and the key text at the same time. What I mean is something along the lines that has been said: look for certain key words like “the” or better yet, longer ones like “that” or “would” and rotate them through the cipher text at progressive offsets and see if any yield an English-like sequence of letters. If so, then, try guessing what the previous or following letters might be. For example, if the key word “THAT” yields the sequence “INVA” then try seeing what happens by guessing “SION” (to complete “invasion”) does to the possible keyword there. If you get “THEF”, you might try “ollowing” (hoping the key text is “that the following”) if that yields junk try “irst” (“that the first” and so on.) And you work iteratively back and forth through the keytext and plain text to figure each other out, as it’s a simple ROT cipher, letter by letter. Or if you know it’s likely the word “NORMANDY” or “TOMORROW” is encoded in the ciphertext, work backword from that assumption and see if any likely hits in the key text turn up.

Something like that. It’s not a fully realized thought yet, as I have to run out the door, but I’m thinking that sort of approach.

---

<div class="post-metadata">

**Author:** ![griffin1977](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@griffin1977](https://boards.straightdope.com/u/griffin1977)\
**Post date:** [November 5, 2021, 8:05pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/22 "2021-11-05T20:05:02Z")

</div>

> [@SpacemanSpiff\_II](#):
>
> Even if you can subtract some common English strings and decipher some of the plaintext, 1) you won’t necessarily know that you’ve deciphered part of the plain text (as opposed to being a random result), and 2) even if you do, you will only know that text is from a book which contains the word THE or AND, which does nothing for you for the rest of the cipher.

Additionally to other comments, remember its a two-way relationship. If you find a “THIS” in the key, you can use that as a hint as to what comes next (“is” is a good guess). And once you correctly guess (which, as others have said, is obvious because what comes out is English not random gibberish) then the you can do the same thing from the plaintext to the key (i.e. if the key “this is” reveals “nd this” in the plaintext then you are pretty sure the letter before is ‘a’).

Once you’ve decrypted a lot of things like this you’ll probably have a bunch more clues to go on (e.g. if the book has a main character called “Fred” you will find that out pretty quickly and than can be used as a clue)

For these reasons, even if you follow all the rules of one-time-pad cyphers (you happened to have thousands of books that only exist at your house and the house of the person who will be decrypting the message, and never repeat them), but use plain-text human language as the key rather than random number, its still super weak decryption.

---

<div class="post-metadata">

**Author:** ![cincinnatus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cincinnatus/32/7990_2.png) [@cincinnatus](https://boards.straightdope.com/u/cincinnatus)\
**Post date:** [November 5, 2021, 10:00pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/23 "2021-11-05T22:00:49Z")

</div>

> [@markn\_1](#):
>
> If you subtract AND from 3 letters of the ciphertext and get the result XFP, it is almost certainly not a correct decryption.

Help me here, please.

How do you subtract AND from text?

---

<div class="post-metadata">

**Author:** ![cincinnatus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cincinnatus/32/7990_2.png) [@cincinnatus](https://boards.straightdope.com/u/cincinnatus)\
**Post date:** [November 5, 2021, 10:18pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/24 "2021-11-05T22:18:27Z")

</div>

And . . .too late for edit . . . we seem to have some pretty savvy crackers here. Who can crack this simple cypher? Please tell how long it took You and how you did it.

SDRAW KCABS ITIHG UOTHN EVEDR AHOOT EBTON DLUOH SSIHT

---

<div class="post-metadata">

**Author:** ![griffin1977](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@griffin1977](https://boards.straightdope.com/u/griffin1977)\
**Post date:** [November 5, 2021, 10:20pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/25 "2021-11-05T22:20:43Z")

</div>

> [@cincinnatus](#):
>
> Help me here, please.
> 
> How do you subtract AND from text?

Just treat letters as numbers, 0 to 25 (as computers always start from 0), and then arithmetic wraps around (so A=0 and 0-3 wraps around to -3, or 23, which means X)

---

<div class="post-metadata">

**Author:** ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)\
**Post date:** [November 5, 2021, 10:38pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/26 "2021-11-05T22:38:32Z")

</div>

> [@cincinnatus](#):
>
> SDRAW KCABS ITIHG UOTHN EVEDR AHOOT EBTON DLUOH SSIHT

> Backwards words say to youI: “Again go I there. Shit, oh!”. — George Carlin

Stranger

---

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [November 5, 2021, 10:39pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/27 "2021-11-05T22:39:01Z")

</div>

Is there something beyond the immediately obvious (which seems to contain an error, too?)

---

<div class="post-metadata">

**Author:** ![cincinnatus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cincinnatus/32/7990_2.png) [@cincinnatus](https://boards.straightdope.com/u/cincinnatus)\
**Post date:** [November 5, 2021, 10:48pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/28 "2021-11-05T22:48:45Z")

</div>

Even spies make typos.

---

<div class="post-metadata">

**Author:** ![griffin1977](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@griffin1977](https://boards.straightdope.com/u/griffin1977)\
**Post date:** [November 5, 2021, 11:09pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/29 "2021-11-05T23:09:59Z")

</div>

Indeed many a decrypt has been based on slopiness or typos from a specific operator. One of the flaws in the Enigma is it required the user to enter a random setting (by choosing three random letters) as part of the encryption process, and it turns out humans are really bad at coming up with random letters (one common setting that operators used was Hitler’s initials) so this was one of the ways Bletchley Park decrypted it.

---

<div class="post-metadata">

**Author:** ![Sage\_Rat](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sage_rat/32/399_2.png) [@Sage\_Rat](https://boards.straightdope.com/u/Sage_Rat)\
**Post date:** [November 5, 2021, 11:31pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/30 "2021-11-05T23:31:15Z")

</div>

I’m not sure how a cryptographer really approaches a problem like this but one thing that I notice is that if we don’t loop the numbers then you’re going to create a modified normal curve on the distribution of values.

It’s like if you roll two dice and add their values together, a 2 and a 12 are fairly uncommon, whereas a 7 is quite likely. When you add two sets of random numbers, you get a normal distribution on the output.

a+a, for example, is the only way to get a 2. Likewise, z+z is the only possible configuration to output a 52. We can pretty quickly work back to the original text of both the original text and the cypher.

While applying a modulus 26 will make this a little less readily apparent, there would probably be a notable skew to the distribution of numbers.

Given that adding letters to letters is fairly common, there’s a fair chance that they’d guess that as a cause of the skew and find your distribution to match what we would expect from adding random texts together.

Once you do that, you can start to statistically work back to the most likely letters and thence the most likely words.

---

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [November 6, 2021, 12:42am UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/31 "2021-11-06T00:42:55Z")

</div>

> [@Sage\_Rat](#):
>
> I’m not sure how a cryptographer really approaches a problem like this but one thing that I notice is that if we don’t loop the numbers

There’s no numbers in this cipher. And, yes, it does loop around. It’s just a type of rotation cipher where the rotation value changes each character. So if “a” codes to “b” and “b” to “c”, then at “z” we get it looping around to code to “a.”

(Unless I’m misunderstanding what you’re saying, of course)

---

<div class="post-metadata">

**Author:** ![Sage\_Rat](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sage_rat/32/399_2.png) [@Sage\_Rat](https://boards.straightdope.com/u/Sage_Rat)\
**Post date:** [November 6, 2021, 12:46am UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/32 "2021-11-06T00:46:54Z")

</div>

> [@pulykamell](#):
>
> There’s no numbers in this cipher. And, yes, it does loop around. It’s just a type of rotation cipher where the rotation value changes each character. So if “a” codes to “b” and “b” to “c”, then at “z” we get it looping around to code to “a.”

In cryptography, there’s no real distinction between a letter and a number.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [November 6, 2021, 1:07am UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/33 "2021-11-06T01:07:02Z")

</div>

You wouldn’t get a bell curve, because of the cyclical boundary conditions, but you probably would still get a telltale spectrum of letter frequency that would reveal to an attacker that you’re using a code like this. For instance, since ‘e’ is common in both your plaintext and in your keys, ‘e+e’ (that is, ‘j’) would be common in the ciphertext.

---

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [November 6, 2021, 2:03am UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/34 "2021-11-06T02:03:03Z")

</div>

Actually, to the OP, if you look at Wikipedia article on running key ciphers under the “Security” heading, it provides a better explanation of the attack method I tried to explain above:

> **[Running key cipher](https://en.m.wikipedia.org/wiki/Running_key_cipher)**
>
> Pages for logged out editors learn more
> 
> In classical cryptography, the running key cipher is a type of polyalphabetic substitution cipher in which a text, typically from a book, is used to provide a very long keystream. Usually, the book to be used would be agreed ahead of time, while the passage to be used would be chosen randomly for each message and secretly indicated somewhere in the message.
> The text used is The C Programming Language (1978 edition), and the tabula recta is the ta...

---

<div class="post-metadata">

**Author:** ![md-2000](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@md-2000](https://boards.straightdope.com/u/md-2000)\
**Post date:** [November 6, 2021, 4:28pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/35 "2021-11-06T16:28:20Z")

</div>

The main flaw here is obviously, using plain text as the key - whereas a one time pad uses randomly selected sequences of letters. Because English sequences are recognizable (“SIHT”) it makes decryption too easy. Also, if the sequence is in the message or the key, the effect is the same. In fact, the extra long key of English words makes things even easier because the likelihood of encountering several common English words gets more likely. (Which is also a factor in other decryptions, that volume of data makes the work easier)

---

<div class="post-metadata">

**Author:** ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)\
**Post date:** [November 6, 2021, 5:04pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/36 "2021-11-06T17:04:41Z")

</div>

> [@griffin1977](#):
>
> Indeed many a decrypt has been based on sloppiness or typos from a specific operator.

In addition to the sloppiness you mentioned, a failure of ciphers is including known (or easily assumed) plaintext such as a standard greeting or name at the end. In this sense, the cipher has the same failure point as the Enigma in that no letter will ever map to itself.

---

<div class="post-metadata">

**Author:** ![Sage\_Rat](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sage_rat/32/399_2.png) [@Sage\_Rat](https://boards.straightdope.com/u/Sage_Rat)\
**Post date:** [November 6, 2021, 5:23pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/37 "2021-11-06T17:23:17Z")

</div>

> [@Chronos](#):
>
> You wouldn’t get a bell curve, because of the cyclical boundary conditions

> [@Sage Rat](#):
>
> if we don’t loop the numbers

Indeed.

---

<div class="post-metadata">

**Author:** ![dtilque](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dtilque](https://boards.straightdope.com/u/dtilque)\
**Post date:** [November 6, 2021, 6:03pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/38 "2021-11-06T18:03:04Z")

</div>

> [@Saint\_Cad](#):
>
> In addition to the sloppiness you mentioned, a failure of ciphers is including known (or easily assumed) plaintext such as a standard greeting or name at the end.

Indeed. The US Navy procedure to defeat that form of decription lead to the infamous “the world wonders” message in WWII.

> **[The world wonders](https://en.wikipedia.org/wiki/The_world_wonders)**
>
> "The world wonders" is a phrase which rose to notoriety following\[a\] its use during World War II when it appeared as part of a decoded message sent by Fleet Admiral Chester Nimitz, Commander in Chief, U.S. Pacific Fleet, to Admiral William Halsey Jr. at the height of the Battle of Leyte Gulf on October 25, 1944. The words, intended to be without meaning, were added as security padding in an encrypted message to hinder Japanese attempts at cryptanalysis, but were mistakenly included in the deco Du...

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [November 6, 2021, 8:35pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/39 "2021-11-06T20:35:07Z")

</div>

And a lot of the German Enigma transmissions included “Heil Hitler”, among a number of other common phrases.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [November 6, 2021, 8:40pm UTC](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811/40 "2021-11-06T20:40:18Z")

</div>

As I recall, Enigma decryption was aided by the references to Hitler at the end of messages, and weather reports at the beginning.

Checking… [Lecture on Naval Enigma - Tony Sale](https://www.codesandciphers.org.uk/virtualbp/navenigma/navenig9.htm)  
Evidence for the Hitler references is a little more sparse

[Previous page](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811.md?page=1)

[Next page](https://boards.straightdope.com/t/how-would-cryptographers-break-this-type-of-code/953811.md?page=3)
