An amateur cryptologist's look into the world of codes and ciphers.
Don't wanna be here? Send us removal request.
Text
A-one, A-two, A-one-two-three-four (Part 1)
So what do I mean by bigrams and trigrams?
Well, n-grams are sequences of n elements that are subsets of another sequence. For example, a 5-gram of Marmalade can be marma (Marmalade), armal (Marmalade), rmala (Marmalade), malad (Marmalade), and alade (Marmalade). Bigrams are 2-grams, and trigrams are 3.
But what does it have to do with ciphers? Well, it's because you might have used it before.
Playfair is a great example of bigrams in ciphers. First, you create a 5x5 square (it can be any size, really, but 5x5 are the most common). Since our alphabet has 26 letters, that does mean that one of them will get left out. But which one? Well, let's look at the distribution of letters. This basically mean that within a text, how likely is it that a certain letter will appear? This has many applications, one of which is for when you intercept a monoalphabetically-encrypted message. Knowing the frequency of which a letter might appear is very useful, because it will minimize going through the alphabet. Since E is the most common, and the least commons are J, Q, X and Z (also the four highest-scoring tiles in Scrabble, if you're into that), you can make a table of frequency, and tentatively put the most common letter as E. The short story "The Gold-Bug", by Edgar Allan Poe, makes a great example for using this to crack the titular code.
But back to our friend Playfair. The usual letter for them is J, and they are interchangeable with I.
This is an unkeyed square (yes, as with anything else, you can key this), and the way that it works is you take two letters from your string, and follow this:
If your letters are on the same row, shift them one to the right, wrapping around if going over the edge. So NO will be OP, for instance.
If your letters are on the same column, shift them one down, wrapping around if going over the edge. So TO will be YT.
Otherwise, find the rectangle that has them as opposite corners, and the letter that comes first in your plaintext will be encrypted as the letter on the same row with that letter. So PI would be OK.
If you have the same letter twice, then you can choose to not do anything, move it one down right, or change the second one to another letter (preferably one of J, Q, X, Z) and return to the top. So OO can be OO, UU, or NY. Just keep it consistent, and you should be fine.
If you have a letter that is not in the grid, exchange it for one that is. For J, that will be I.
My encrypted text: HNTGT NDACL FBSMDU
A trigram-using cipher is slightly harder to find, but it doesn't mean that it's impossible. The Delastelle Trifid, so named because its creator is Félix-Marie Delastelle, is one such cipher. This is an extension of Delastelle's earlier Bifid cipher, another of our bigram ciphers.
As with Playfair, we need a grid. But... not just a grid. We need three grids. Three 3x3 grids. The more mathematically inclined among us may realize it as containing 27 possible spaces, which is just enough for the alphabet plus another character. You can use whatever symbol here, but I'll use a dash: -. And as with a lot of things, you can key this.
The way it works is that you translate the letters into 3-digit numbers. The first number is the layer (the number in the corner denotes this), the second the row, and the third the column. So N would be 222, for example. The numbers would be written straight down underneath the letters, and then the next step is choosing a periodic number. A good tip here is to choose a number coprime with 3 (as this will help diffuse the message). I will choose 5. The last step is to divide up the message into chunks of your number of choosing. Read the digits three at a time going across, and write down the character it corresponds to.
My encrypted text: HMHU-A MUJHHB DNZDK
They seemed like they couldn't be bested, and it's true... for a while. But everything must yield before time.
So how were they cracked?
0 notes
Text
Divisions of Codes and Ciphers
There are two kinds of codes/ciphers: transpositional, where your characters are the same, just moved about (like an anagram with a precise way to revert the encrypted text to the message), and translational, where your characters are in the correct position, but it's not the same characters (like a masquerade party).
The earliest transpositional cipher one would normally think of is good old Scytale. Imagine you have a tube, and wrapped around said tube is a strip of cloth. You have to make two decision: - How many sides does the Scytale have? - How many times can you wrap the strip of cloth around the tube? You have that? Good. Now, you write your message on the strips on the tube. For me, my Scytale has six sides, and I can wrap my strip four times around. After you've done this, you can unwrap the strip of cloth. What you should see is a bunch of characters with no rhyme or reason to it. The receiver, on receiving the strip of cloth, would wrap it around a tube of similar dimensions, and they would be able to read the message. My encrypted text: WSEARLIHSYULLIAFSLNWOA
The earliest translational cipher one would normally think of is our friend Caesar. Shift forwards/backwards by a number less than 26 (the number of letters in the English alphabet) to get a completely new one. My encrypted text: JURA GURER'F N JVYY, GURER'F N JNL.
While these are good in their time, there's just one problem if you use it now: It can be bruteforced. What do I mean by bruteforce? Well, let's look at the case for Caesar.
Since Caesar only has 26 possible configurations (assuming you're using the normal, unchanged alphabet), you can simply write out all 26 configurations, and see which one looks the most intelligible. For "JURA GURER'F N JVYY, GURER'F N JNL", it'll end up something like this.
KVSB HVSFS'G O KWZZ, HVSFS'G O KOM.
LWTC IWTGT'H P LXAA, IWTGT'H P LPN.
MXUD JXUHU'I Q MYBB, JXUHU'I Q MQO.
NYVE KYVIV'J R NZCC, KYVIV'J R NRP.
OZWF LZWJW'K S OADD, LZWJW'K S OSQ.
PAXG MAXKX'L T PBEE, MAXKX'L T PTR.
QBYH NBYLY'M U QCFF, NBYLY'M U QUS.
RCZI OCZMZ'N V RDGG, OCZMZ'N V RVT.
SDAJ PDANA'O W SEHH, PDANA'O W SWU.
TEBK QEBOB'P X TFII, QEBOB'P X TXV.
UFCL RFCPC'Q Y UGJJ, RFCPC'Q Y UYW.
VGDM SGDQD'R Z VHKK, SGDQD'R Z VZX.
WHEN THERE'S A WILL, THERE'S A WAY
XIFO UIFSF'T B XJMM, UIFSF'T B XBZ.
YJGP VJGTG'U C YKNN, VJGTG'U C YCA.
ZKHQ WKHUH'V D ZLOO, WKHUH'V D ZDB.
ALIR XLIVI'W E AMPP, XLIVI'W E AEC.
BMJS YMJWJ'X F BNQQ, YMJWJ'X F BFD.
CNKT ZNKXK'Y G CORR, ZNKXK'Y G CGE.
DOLU AOLYL'Z H DPSS, AOLYL'Z H DHF.
EPMV BPMZM'A I EQTT, BPMZM'A I EIG.
FQNW CQNAN'B J FRUU, CQNAN'B J FJH.
GROX DROBO'C K GSVV, DROBO'C K GKI.
HSPY ESPCP'D L HTWW, ESPCP'D L HLJ.
ITQZ FTQDQ'E M IUXX, FTQDQ'E M IMK.
JURA GURER'F N JVYY, GURER'F N JNL.
As you can see, the 13th one in the list is the one that is the most legible. If you don't know a key, you can bruteforce it. If there's not a lot of possibilities, then you get this situation, which both Scytale and Caesar has. Scytale fares a bit better, but it is still bruteforceable.
But there is a way to make the Caesar a bit stronger: key it. There are 26 letters of the alphabet, so there are 26! (26 factorial, basically the product of every number from 1 to 26) alphabets to choose from. The normal progression of the alphabet is but one of the ways to choose.
The problem with that, however, is that it's still very, very crackable. Anyone who has played Cryptogram before knows how easy it is to crack it without a key. Even if you have to use bruteforce to check, it's still rather solvable.
So we have to ramp it up somehow, but how? Enter: bigrams, trigrams, and polyalphabetic ciphers
7 notes
·
View notes
Text
Welcome!
To whoever might be reading, Welcome to my little corner of the tumblr-verse.
Here, I'll try and put out things that I find interesting in my area of interest: codes and ciphers.
Historically, codes and ciphers have been there since a need to transfer messages secretly arises. Granted, the first solutions aren't within that space of codes and ciphers, but rather steganography. Writing messages on messenger's scalps, or hiding it on the wood under a layer of wax, while a great idea, could be rather time-consuming (waiting for hair to grow back), and very damaging if the information is intercepted by a third party.
How, then, to make the information unreadable but to the intended recipient?
That's where codes and ciphers come in.
2 notes
·
View notes