Serious about cryptanalysis? Learn a programming language!

Example of cryptanalytic program written in Perl

Cryptanalytic program written in Perl

I’ve been a computer programmer since the early 70’s, about the time I became enamoured with cryptanalysis.  Writing computer programs to aid my cryptanalytic research has been invaluable to me throughout this entire period.  Sure, I have spent delectable hours solving ACA-type cryptograms by hand.  When I worked on more serious ciphers in university, however, computers have always been invaluable and time-saving.

My first cryptanalytic programs were written in PL/1 and ran on IBM mainframes.  The speed of these babies matched that of modern day PCs.  In the 80’s I “graduated” to PCs running compiled C code and the occasional AWK scripting program to help analyze and solve more sophisticated ciphers.

For many years my cryptanalytic scripting language of choice was AWK.  When all I wanted to do was parse the ciphertext, perform a frequency count, and perform some complex analysis, a scripting language is light enough for the classic edit-run-debug loop.

A few years later I moved on to Perl.  Here was a scripting language that let me do anything I pleased in a minimal amount of coding time.  My research output increased significantly and I was able to produce important results I could never have done by hand.

An example of results I could never have done manually is the initial work I did on John F. Byrne’s Chaocipher.  Sifting through the 13,300+ characters of Exhibit 1, looking for pt/ct identities, plaintext and ciphertext double letters, isormorphs, trawling a pattern through the plaintext or ciphertext looking for a match, performing statistical calculations, simulating alternative cipher models and enciphering the 13,300+ plaintext characters — these are only a few of the tasks that scream out for automation using computers.

Recently I spent time trying to solve a single ADFGVX ciphertext challenge message.  The tremendous amount of tedious and error-prone computations and calculations needed to match columns would take days to perform, so I wrote some help program (in Perl) that let me concentrate on the analysis without getting bogged down in the “drudgery”.

Up-and-coming cryptanalytic techniques we’re seeing more and more are Hill-Climbing and Simulated Annealing (SA).  You can only take advantage of these powerful methods if you can write a program to do it for you.

You don’t need to study Advanced Computer Science to be able to write computer programs.  Pick a language (e.g., Perl, C, C++, Ruby, Python, Visual Basic, Java) and start writing simple programs: reading text from a file, taking a frequency count, writing to standard output, manipulating characters and strings, loops, and performing mathematical calculations.  In a short time you will have mastered everything you need to write cryptanalytic aids.

Don’t worry if you don’t know the difference between a double-linked list and a B-tree.  Just program the method you would use if you were solving it by hand.  This alone will cut your solving time by 1-2 magnitudes.

In my opinion, every cryptanalyst should know how to write computer programs to ease the work.  And I believe anyone can acquire that skill.

Don’t lose out on advancing in the world of Classical Cryptanalysis because the problem key space is too large for manual solution and you can’t program.  Take that step, come on into the modern world, and let your cryptanalytic achievements soar.

Advertisements

15 Responses to Serious about cryptanalysis? Learn a programming language!

  1. Rupa says:

    Hi,
    Can you pls tell me which course to intiate for cryptography.I have a keen interest on cryptography but am an commerce graduate and would like to know the basic course for beginners as i can take it frm there,Pls advise.

    Thanks & Regards
    Rupa.

    • mosherubin says:

      Hi Rupa,

      You’ve caught me unprepared! My advice about learning how to program by learning a small programming language still stands. What I think I need to do is write a series of blog postings describing the rudiments of a particular programming language (which one?), then showing how to write simple but powerful cryptographic and cryptanalytic programs solving real ciphers.

      So, with your permission, I will author a series of lessons on writing cryptographic/cryptanalytic computer programs (I’ll need to decide which programming language to use). A possibility is to post the series on The Crypto forum for a more appropriate venue (BTW, you will find very interesting cryptologic discussions there).

      In any case, I will post a blog entry here announcing the availability of the series.

      Thank you for raising the issue and pushing me to take this important step.

      Moshe

  2. Rupa says:

    Hi,
    Thanks for your prompt response.I really appreciate your efforts to encourage and help beginners like me.I am also looking forward to your lessons.Will you post it on the same blog or please send me the link..

    Thanks & Regards
    Rupa.

    • mosherubin says:

      Hi Rupa,

      I’ll decide soon where to publish the series, but I will most certainly post an entry on Jerusalem Mosaics pointing to the eventual location.

      Thanks again,

      Moshe

      • Arlan Blodgett says:

        Hi Moshe ~ Have you written your Crypto program on programing yet and if so where can I download the lessons. I have a Pen and Paper “unsolveable” cipher that I created and I want to put it in a computer so I can play with it a little.

        So you live in Jerusalem. Yes, that’s a great city – been there done that back in 1997 and 99 when I was in Iseral on a dig up by the Sea of Galiliee with Dr Yosef Garfinkel @ Kibbutz Sha’ar Hagolan, those were very interesting summers before the big walls went up. arlan b.

      • mosherubin says:

        Hi Arlan,

        I’m sorry to report that I have not yet created my tutorial on cryptanalytic programming. This is a project of love that will have to wait until I free up. A few months ago, I made the conscious move to switch from Perl (my first love) to Python. One of the main reasons for doing so is the ease in creating and maintaining a library of functions in Python in contrast to Perl. As osric has nicely handled the Python tutorial scene, I will have to see what I can add.

        I admit I’m biased : Jerusalem is a wonderful and unique city, as you intimate. Dr. Yosef Garfinkel is a well-known professor of archaeology — I’m sure it was an experience you won’t forget too soon.

        Best regards,

        Moshe

  3. osric says:

    Hi Rupa,

    I’m sure Moshe will provide an excellent Tutorial, drawing on his expert knowledge of both cryptology and computer programming.

    While he is preparing his articles you might like to have a look at a Tutorial I’ve prepared for beginners on programming with Python. Python is a modern, high-level language which is easy to learn and free to download. I am also a keen cryptologist and have written the Tutorial with cipher-solving in mind.

    If you are interested, have a look at my website

    http://web.me.com/mikejcowan/Ciphers/Welcome.html

    Osric

  4. osric says:

    Hi Arlan Blodgett,

    Well I’m amazed because the whole article prints out fine on my computer/printer. I think you need to look at the settings on your equipment — or buy some new kit!

    On my computer I can copy my article from the web onto my clipboard, and then paste it into a Word document and print the document. That should work for you also, and I hope it helps you solve the problem.

    Oh and by the way my name is osric, not orsic.

    • Arlan Blodgett says:

      Hi Osric ~ I’m back after over a year ~ got side tract a little. I’m still having about the same problem. I have the same printer HP Officjet 6500 but have upgraded to using Windows 7 about 5 months ago in a brand new ACER computer, my XP and old computer were 6 years old.

      Here is what happens trying to print your “Encipher” – the printer runs through all 7 pages with complete info at the very top and bottom of pages [page 1 of 7 and page 2 of 7, etc] but only printed the complete page of “1” and “7” all the rest were Blank in the middle of the page. In all of my 21 years of computing this has NEVER happened. My computer expert suggested it has to be on your end of the system but he doesn’t understand what is going on. Is there a chance of you sending a copy as a attachment to email or something?? Later Arlan Blodgett

      PS where do you live in Israel?

      • mosherubin says:

        Hi Arlan,

        Moshe Rubin here (blog moderator). osric lives in the UK — I’ll ping him and tell him about your post. I myself live in Jerusalem.

        Regards,

        Moshe

  5. osric says:

    Hi Arlan,

    I must confess that I should have posted a downloadable text file of my article on Python for folk who would rather read from hardcopy than screen — and I will get round to doing that, hopefully within another year! I’ll let you know when I’ve done it.

    osric

    • Arlan Blodgett says:

      OSRIC ~ I hope it isn’t going to be another year. I just turned 79 a few months ago and my thinking matter needs some excersize to keep going. I have developed a Pen and Paper “Unsolovable” cipher and I need to convert it to a computer so I can play with it a little more.

      So you live in UK but what part? My family moved from Haughley/Stowmarket England in 1635 to Boston. Was up there about two years ago, no Blodgett’s left after all those years. Nice country. Have a great day. arlan b

      • mosherubin says:

        Hi Arlan,

        One would need access to your specific printer driver, drilling down to the exact output stream to see if there is a control character causing the problem. You might want to do the following workaround:

        1. Install a free PDF printer driver (e.g. Nitro Reader or PDF995).
        2. Print the “Encipher” page to the PDF driver. This should create a PDF document on your disk with all 6-7 output pages
        3. Print the PDF document to your HP OfficeJet

        It’s a way of cutting the Gordian knot rather than solving the specific printer driver-related issue. Hope this helps.

        Moshe

  6. Computers has risen alots during the past years! I’ve compiled a blog of information about the evolution of Technology…

    […]Serious about cryptanalysis? Learn a programming language! « Jerusalem Mosaics[…]…

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

%d bloggers like this: