Sunday, May 4, 2014

Cryptanalysis


Hurrah!!!! Finally implemented the algorithmic code to decrypt a cipher text message without looking at Internet. (Internet sometime makes you lazy nutshell as a calculator sometimes)

The exercises taken from the book "Security in Computing, Fourth Edition By Charles P. Pfleeger". It doesn't say whether it was Substituted or Transpositioned, you have to find it by yourself by performing various test. All that was given is ONLY the cipher text. KaBooom...!!

Cipher Text : fqjcb rwjwj vnjax bnkhj whxcq nawjv nfxdu mbvnu ujbbf nnc

Let's start with the easiest. The Substitution with Ceaser cipher which is a mono-alphabetic cipher.



From the above code segment, first we captured the ciper text using a scanner, so we can enter whatever the cipher text we want to decrypt through the console. Then we arrange it as a character array and looped it to count how many characters are there in the ciphertext for each character. This was done for the displaying purpose. But the important, and most necessary thing we do is, through the loop, we identify what is the character with maximum counts. So for the above code segment we get the following output.

  : 9
A : 2
B : 5
C : 3
D : 1
F : 3
H : 2
J : 7
K : 1
M : 1
N : 7
Q : 2
R : 1
U : 3
V : 3
W : 4
X : 3


max char : J

"J" is the character with maximum count we first encounters in the text. 

People who involved with cryptography for a long time had identified that the four letters A, E, O, and T account for approximately 40 percent of all letters used in standard English text. So this "J" could be either 1 of these 4 characters. So next what we are doing is replacing "J" with 1 of these 4 characters and create the new alphabet. Let's start with "A".


If we go through this createAlphabet(maxChar, choosedChar) method we can findout how the new alphabet was created according to the Ceaser cipher using the fact that the English alphabet has 26 characters.




So now with the second code segment we can get the following final output. 

Original Text : WHATS INANA MEARO SEBYA NYOTH ERNAM EWOUL DSMEL LASSW EET

If we analysed the text we can identify that the text include some meaningful words without meaningful separation. Let's see manually if we can separate the words.

WHATS IN|A|NA ME|A|RO SE|BY|A NY|OTH ER|NAM E|WOUL D|SMEL L|AS|SW EET

WHATS IN A NAME A ROSE BY ANY OTHER NAME WOULD SMELL AS SWEET

Victory!! We nailed the Romeo and Juliet. "what matters is what something is, not what it is called." 





Check whether you got the following answers for other exercises. And see where does the messages comes from.


2) Cipher Text : oczmz vmzor jocdi bnojv dhvod igdaz admno ojbzo rcvot jprvi oviyv aozmo cvooj ziejt dojig toczr dnzno jahvi fdiyv xcdzq zoczn zxjiy

Max Char : O - 18 counts 

Replaced By : T

Plain Text : THERE ARE TWO THINGS TO AIM AT IN LIFE FIRST TO GET WHAT YOU WANT AND AFTER THAT TO ENJOY IT ONLY THE WISEST OF MANKIND ACHIEVE THE SECOND


By Logan Pearsall Smith

3) Cipher Text : pbegu uymiq icuuf guuyi qguuy qcuiv fiqgu uyqcu qbeme vp  

O.. Oh..O!!! now it's time to change the approach. What approach should we take now?





PS : I found a nice little tool called SyntaxHighlighter to embed source codes nicely on the blog posts. Isn't that look smart.


No comments:

Post a Comment