Tag Archives: julia,cryptography,enigma

Building an Enigma emulator and a Bombe

I got a bit distracted on my work of building a constraint solver which is a series of 17 posts now. Check it out if you’re interested in solving sudokus, graph coloring, JuMP or well generally contraint solving. This time I want to show you what I’ve done the last couple of days.

YouTube suggested me this video from Code Bullet about building an Enigma Machine. It was somehow on my imaginary list of things I wanted to code like a sudoku solver some years ago.

Additionally I want to code a chess computer but that’s something for another day.

Alright let’s start with the Enigma. First of all I will shortly explain what it is about then I’ll start with creating the Enigma package in Julia with starting which functions we need to encrypt and decrypt messages.

In the second part you can read more about the flaws of the Enigma machine and how they can be used to crack the code so decrypt messages without knowing the setting.

A bit of a story

The Enigma was used in the World War II by the Germans to have a secure communication in their military. They thought that their machine is sooo good that it is unbreakable. Well they weren’t the first to think that about a new cryptographic technique and probably not the last. The code was famously cracked by Alan Turing and others at Bletchley Park during the war. Which means that they were able to save a lot of lives and end the war earlier.

Maybe you have seen the movie The Imitation Game with Benedict Cumberbatch about that story. Even though it is simplified as always it is a good movie.

Because we dive into the actual Enigma Machine we might want to have a very short look at previous methods of decrypting and I’m not an expert on this so it’s just a short overview of simple methods that I find interesting.

First part of every cryptography section should be the Caesar method where one only replaces a letter with a different letter and even simpler just moving the alphabet by a number of steps like this.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
G H I J K L M N O P Q R S T U V W X Y Z A B C D E F 

Things that come to mind if cracking such codes are:

  • Is it safe even if they know the method but not the settings?
  • How many possibilities are there?

In this case there are only 26 setting and one of them is the plain text so it is obviously not good if you know the method.

What if we just randomly set the letters instead of shifting?

A B C D E F G H I J K L M N O P Q R S T...