Secrets of Cryptograpy/Programming

Secrets of Cryptograpy/Programming

A Story by Paul Ramnora
"

Currently, I'm studying cryptography by reading Simon SIngh's book, called: The Cracking Code book. It contains certain cryptograms that readers can practice doing their code cracking skills on. I used QBASIC programming language to help.

"

I'M CURRENTLY PRACTICING DOING SOME QBASIC CODING…

I was just reading through a very interesting book called: The Cracking Codebook. It is written by author Simon Singh. At the back of the book; on pages: 243/244, it suggests 4 cryptograms that allows readers to practice their code cracking skills; with each one of these puzzles being increasingly more difficult to crack than was the one before it. Anyway, here is the first cryptogram which should be the easiest of the 4 to go and decode…(I will work on decoding the rest, afterwards)...

CIpertext:

L FDQQRW IRUHFDVW WR BRX WKH DFWLRQ RI UXVVLD LW LV D ULGGOH ZUDSSHG LQ D PBVWHUB LQVLGH DQ HQLJPD XLQVWRQ FKXUFKLOO

Plaintext(translation):

I cannot forecast to you the action of russia it is a riddle wrapped in a mystery inside an enigma winston churchill

MY WORKING OUT METHOD

The first thing I noticed about the cryptogram, is it looks like being a mixture of variable length letter words/with punctuation spaces showing in between each word.

L FDQQRW IRUHFDVW WR BRX WKH DFWLRQ RI UXVVLD LW LV D ULGGOH ZUDSSHG LQ D PBVWHUB LQVLGH DQ HQLJPD XLQVWRQ FKXUFKLOO

(1) 123456 12345678 12 123 123 123456 12 123456 12 12 (1) 123456 1234567 12 (1) 1234567 123456 12 123456 12345678 123456789

I also noticed that there are, at least, 3 x single letter words being included: (L/D/D).

In the English language there are only 2 single letter words that I know of; and, therse are: (A/I).

By a pure guess, I thought this might be a  sentence quote being spoken; so, I thought it’s highly likely that the word ‘I’ is being used here to begin the sentence/and, therefore, it’s quite likely that the stand alone, L -(which is the letter that starts the ciphertext)- = I; which means that D (the only other single letter/and, which is repeated twice in the Ciphertext) = A.

Next, one realises that both ‘A’/'I’ are also common vowel letters, as well; as opposed to being much rarer constant letters; thus, it’s simply a matter of replacing each L with I/and, each D with A; and, already we are making some headway towards guessing what this code is.

CIpertext(original):

L FDQQRW IRUHFDVW WR BRX WKH DFWLRQ RI UXVVLD LW LV D ULGGOH ZUDSSHG LQ D PBVWHUB LQVLGH DQ HQLJPD XLQVWRQ FKXUFKLOO

CIpertext(after replacing each L with I/and, each D with A):

I FAQQRW IRUHFAVW WR BRX WKH AFWLRQ RI UXVVIA IW IV A UIGGOH ZUASSHG IQ A PBVWHUB IQVIGH AQ HQIJPA XIQVWRQ FKXUFKIOO

-(I could have tried ‘very slowly’ guessing, and, replacing even more letters; but, no, I decided to try another way which is far quicker.)-

My next major guess here is that this Ciphertext is, in fact, using the Caesar Shift encoding method; which deals with alphabet letter repositioning(eg. A+1=B/A+2=C/-etc). That must mean, all I have to do to find out exactly what the Caesar Shift code number is; and, then, I will be able to discover exactly what ‘all’ of the letters in the code mean.

So, having already worked out what 2 individual letters mean: L=I/D=A. I have to count what is the alphabet letter position of both L(I)/D(A)? L, which is letter 12 of the alphabet, if we count backwards to get to I…becomes I by a count of -3. (I=9/J=10/K=11/L=12). And, similarly, with D; if we count backwards to get to A….becomes A also by a count of -3. (A=1/B=2/C=3/D=4). Thus, it’s most likely that the Caesar Shift number must be -3.

My next step is to test if -3 really does work/or, not? So, having already decoded the first word: L=I/I now need to decode the 6 letter length 2nd word by using the Caesar Shift number -3.

FDQQRW

…using Caesar Shift of -3 for each letter we get…

F=6-3=3=C

D=4-3=1=A

Q=17-3=14=N

Q=17-3=14=N

R=18-3=15=O

W=23-3=20=T

…and, eureka! Success! It spells the english word: cannot. Thus, at this stage we’ve already managed to manually figure out that…the start of the code…

L FDQQRW

…means…

I cannot

At this point there is no need for me to try doing any further manual translation of the code; simply because computers work a hell of a lot more faster at doing this sort of thing; so time to get down to creating a computer program to do the rest of the job, automated, instead.

-(NOTE: By just merely doing a few guesses to start with; I didn’t need to quite tediously try every possible Caesar Shift number ranging through from 1-26; and, consequently, the job of writing a computer program to solve the problem will be considerably shortened; simply, by already knowing that the Caesar Shift number is -3.)-

==========

Pseudocode:-

a) Clear screen

b) Get the Caesar Shift code number (-3)

c) Get the Cipertext

d) Let the program do the decoding

e) Printout the decoded plaintext

f) Ask the user if they wished to re run the program again/or, not? If (Y)es; then, start back at step a); and, if (N)o; then, END the program.

==========

QBASIC CODE

For those who may be interested in what the actual program code I wrote looks like; then, here it is the full listing for you to view…

QBASIC CODE LISTING/START/(122 lines)…

====================

‘————————————
‘*** PROGRAM: Caesar Shift Decoder…
‘ LANGUAGE: QBASIC, Version 1.1
‘ PLATFORM: PC/WINDOWS XP

‘ Author: paul ramnora
‘ Email: [email protected]
‘ Location: UK/London

‘ CREATED: 04:07 08/02/2009 GMT.
‘ UPDATED: 04:07 08/02/2009 GMT.
‘————————————

‘*** COMMENTS: This program asks the user to enter 2 items of data…

‘ A) Caesar Shift Code number:
‘ Valid ranges are positive: 1-26/and, negative: -1/-26

‘ B) Ciphertext to be decoded to become plaintext

‘ Then, the program will use the above data entered
‘ to both decode/and, print out on screen the decoded plaintext.

‘ NOTE: It’s possible for the program to be used to both
‘ encode/decode data, as well.

‘ Eg. you could enter…
‘ Caeser shift code +3 to encode plaintext/
‘ and, -3 to decode the resulting ciphertext.

‘—————————-
‘*** Variable declarations…
‘—————————-

‘*** integer: (int/%)…

intAlphabetLetterNo% = 0
intCaesarShiftCodeNo% = 0
intEachChar% = 0

‘*** string: (str/$)…

strASpace$ = ” ”
strDecodedText$ = “”
strEachLetter$ = “”
strUnderlineChar$ = “_”
strUserText$ = “”
strYesNo$ = “”

‘——————-
‘*** Main program…
‘——————-

GOSUB clearScreen
GOSUB printTitle
GOSUB printUnderline

GOSUB getCaesarShiftNumber
GOSUB printUnderline

GOSUB getCipherText
GOSUB printUnderline

GOSUB decodeText

GOSUB printDecodedPlaintext
GOSUB printUnderline

GOSUB reRun
END ‘…END of program/halt program code execution

‘——————-
‘*** Sub-routines…
‘——————-

clearScreen:
CLS ‘…(CL)ear the (S)creen
RETURN

printTitle:
PRINT “Caesar Shift decoder”
RETURN

printUnderline:
PRINT STRING$(80, strUnderlineChar$);
RETURN

getCaesarShiftNumber:
INPUT “A) Enter your Caesar Shift code”; intCaesarShiftCodeNo%
RETURN

getCipherText:
PRINT “B) Enter your Caesar Shift ciphertext to be decoded…”
INPUT strUserText$
RETURN

decodeText:
        FOR intEachChar% = 1 TO LEN(strUserText$)
                strEachLetter$ = UCASE$(MID$(strUserText$, intEachChar%, 1))
                IF strEachLetter$ >= "A" AND strEachLetter$ <= "Z" THEN
                        intAlphabetLetterNo% = (ASC(strEachLetter$) + intCaesarShiftCodeNo%) - 64
                        IF intAlphabetLetterNo% <= 0 THEN  'add +26...
                                intAlphabetLetterNo% = (intAlphabetLetterNo% + 26)
                        ELSEIF intAlphabetLetterNo% >= 27 THEN 'deduct -26...
                                intAlphabetLetterNo% = (intAlphabetLetterNo% - 26)
                        END IF
                        strDecodedText$ = strDecodedText$ + CHR$(intAlphabetLetterNo% + 64)
                ELSEIF strEachLetter$ = strASpace$ THEN
                        strDecodedText$ = strDecodedText$ + strASpace$
                END IF
        NEXT
RETURN

printDecodedPlaintext:
PRINT “Here is your ciphertext decoded to become plaintext…”
PRINT strDecodedText$
RETURN

reRun:
INPUT “Again, Y/N”; strYesNo$
IF LEFT$(UCASE$(strYesNo$), 1) = “Y” THEN RUN
RETURN

===================

…QBASIC CODE LISTING/END/(122 lines)

===================

Finally, if you click on the above image -(shown as being a small thumbnail size pic next to the title of this article)-; there you will see what the program RUN/screen display printout looks like.

QBASIC PROGRAMMING LANGUAGE DOWNLOAD LINK

If you wish to try out the above code; then, you can download the QBASIC programming language directly from Microsoft web site...

http://support.microsoft.com/kb/135315

...scroll down to where it says: Other Folder; and, next, choose the link which says: Download olddos.exe now.

THE CRACING CODE BOOK INTERNET LINKS...

The Cracking Code book can be brought online from amazon.co.uk(you can also follow this link to read other people's reviews):

http://www.amazon.co.uk/Cracking-Code-Book-Simon-Singh/dp/000717604X/ref=sr_1_6?ie=UTF8&s=books&qid=1234146869&sr=8-6

Simon Singh's own web site is at:

http://www.simonsingh.net

And, it's worth noting that he has a link on his web site which allows people to either buy a teaching cryptography book on CD ROM/or else, immediately, download it entirely for FREE:

http://simonsingh.net/The_CDROM.html

 

=====

Both essay, and, also, computer screen printout created by me, Paul Ramnora.

(c)copyright, Mr. Paul Ramnora, 2008/2009./All rights reserved. 

 

 

 

 

© 2009 Paul Ramnora


My Review

Would you like to review this Story?
Login | Register




Reviews

Sir, I must ask, WHAT IS THIS?

Posted 15 Years Ago


Interesting indeed. You wrote something that taught me something. I enjoyed this. Thank you for teaching me about codes and such.

Posted 15 Years Ago



Share This
Email
Facebook
Twitter
Request Read Request
Add to Library My Library
Subscribe Subscribe


Stats

1749 Views
2 Reviews
Rating
Added on February 9, 2009
Last Updated on September 20, 2009

Author

Paul Ramnora
Paul Ramnora

LONDON, United Kingdom



About
I like general arts, education, keep fit, martial arts, tv/video's/dvd's, computers and programming/-etc. more..

Writing