Substitution cipher tool

I was reading a textbook for my course and was challenged by the book to break a substitution cipher. A substitution cipher is an mono-alphabetic encryption scheme whereby each letter is substituted by another letter. This cipher scheme is considered weak because it is susceptible to frequency analysis attacks. For example, in English, the letter E is the most common letter, so by analysing the frequency of each letter in the cipher text, it is possible to derive some information about the encryption, in this case, the letter which is substituted by E.

Feeling relatively bored one day, I decided to make a web app to help me solve the challenge. It is pre-loaded with the cipher text from the book if anyone is interested to try but one can simply enter any cipher text in the textbox. What the app does is it provides an interactive platform for the adversary (us) to try and decipher the cipher text, using statistical information such as frequency, digrams and trigrams. To change the substitution, drag the letters in the ‘lang’ row to swap them. This will trigger a change in the decrypted message. The checkbox will cause the letter in the decrypted text to be in uppercase, to ease differentiation between probably correct letters from the rest. One can also insert spaces in the decrypted text and it can be saved by pressing the save button.

Image

When I started building this, I only implemented the letter frequency and was matching the letters based on the frequencies. However, it wasn’t really helpful because firstly, it didn’t produce a readable text from the ciphertext, and analysing a random article on wikipedia (I used ‘philosophy’) showed that the letters could be rotated or swapped. All frequency analysis could do was to classify letters into bands of letters. So I needed something more powerful. Upon doing some research, I realised that most frequency analysis are usually accompanied by digrams and trigram analysis. That made sense because it could ‘correct’ the rotation of letters in a band. So I decided to include that in the app as well. After about an hour of playing around. I finally managed to solve the cipher text. 

If you did not manage to solve it and just want the answer. The obfuscated answer is:

PELCGBTENCUVP FLFGRZF NER RKGERZRYL QVSSVPHYG GBOHVYQ ARIREGURYRFF SBE FBZR ERNFBA ZNAL ABA RKCREGF VAFVFG BA QRFVTAVAT ARJ RAPELCGVBA FPURZRF GUNG FRRZ GB GURZ GB OR ZBER FRPHER GUNA NAL BGURE FPURZR BA RNEGU GUR HASBEGHANGR GEHGU UBJRIRE VF GUNG FHPU FPURZRF NER HFHNYYL GEVIVNY GB OERNX

More code to break:

http://www-math.ucdenver.edu/~wcherowi/courses/m5410/exsubcip.html

CK PKHG VG CKUGZ QAG CKUGCLGPQ FJZ IGPQ QAFQ QLHG FJZ EFQG KE FCC QAGLO ULJQFRG MOGPQ AFUG ZOSJB QAGLO TSM FOKSJZ KO QVK IGEKOG FJZ KJG IX KJG TOGMQ PLCGJQCX QK OGPQ YD 

Advertisements

Published by

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s