Enigma and Cryptography: The Secret War, The Power of Codes, and a Little Go Magic

Welcome to the World of Cryptography!
Picture this: It’s a regular morning, you’re on your way to work, and you text your friend, “Are you coming for breakfast?” But that message is hidden in such a way that nobody but you and your friend could ever understand it. That, my friend, is one of the invisible miracles of modern life: cryptography.
Humanity has been trying to keep secrets for thousands of years. From Ancient Egypt to WhatsApp, cryptography has always been our closest ally! And along the way, we met one of the most mysterious heroes of all: the Enigma Machine.
The Enigma Machine: The James Bond of World War II
Imagine: It’s the middle of World War II. The German army encrypts nearly every message, and breaking those codes is as hard as finding the Holy Grail. Why? Because they have a machine: Enigma.
What I’m about to describe might sound like science fiction, but it’s true: With every key you press, Enigma’s rotors and reflector twist and scramble your message into pure gibberish. It’s like a bowl of alphabet soup—except only Enigma can put the letters back in order!

How Does Enigma Work? (The Spinning Cipher Wheel!)
Picture a vintage typewriter with a twist—every letter you press gets scrambled by spinning gears inside. Only someone with an identical machine and settings can decrypt the message. Here’s the magic:
- You press a key: An electric current starts its journey through the first rotor.
- The rotors spin: With every keypress, the rotors shift, so each letter matches to a different letter every time.
- The reflector steps in: The current bounces off a reflector, back through the rotors, and out comes a brand new letter.
- A light shows your cipher letter: Press “A”, and maybe “G” lights up. Press “A” again, and now it’s “L”. The rotors have moved!
Every single letter turns into a different letter each time you type. Imagine typing “AAAA”—each one comes out different! Millions of possible combinations. When the Allies tried to “hack” it, the Germans said, “Good luck!”
The Secret Breakers: Cracking Enigma
But even Enigma wasn’t invincible. Enter Alan Turing and his genius team. They believed that if they could crack Enigma, they could shorten the war. After endless days and nights, they finally cracked the code!
The tides turned. For the Germans, the “unbreakable” Enigma was now a huge liability. Historians agree: breaking Enigma changed the course of the war and saved millions of lives.
Where Are We Now? (Secret Codes, Still at Work!)
Today, cryptography isn’t just for spies. Every time you shop online, check your bank account, or send a meme, encryption is working behind the scenes. Modern algorithms (AES, RSA, ECC and friends) are everywhere!
And the coolest part? You can experiment with your own encryption algorithm using a little Go code.
Let’s Build a Mini “Enigma” in Go!
Ours may not be as fancy as the real Enigma, but building your own code machine is still a blast! Here’s a simple Go program—a spinning-rotor cipher that shifts each letter by an increasing amount, just like a basic Enigma:
package main
import (
"fmt"
"strings"
)
// Magic rotor-based cipher!
func enigmaEncrypt(input string, shift int) string {
var result strings.Builder
input = strings.ToUpper(input)
for _, r := range input {
if r >= 'A' && r <= 'Z' {
enc := ((int(r-'A') + shift) % 26) + 'A'
result.WriteRune(rune(enc))
shift = (shift + 1) % 26 // The rotor spins one step per letter!
} else {
result.WriteRune(r)
}
}
return result.String()
}
func enigmaDecrypt(input string, shift int) string {
var result strings.Builder
input = strings.ToUpper(input)
for _, r := range input {
if r >= 'A' && r <= 'Z' {
dec := ((int(r-'A')-(shift)+26)%26 + 'A')
result.WriteRune(rune(dec))
shift = (shift + 1) % 26
} else {
result.WriteRune(r)
}
}
return result.String()
}
func main() {
message := "CODES ARE POWERFUL"
shift := 7
encrypted := enigmaEncrypt(message, shift)
fmt.Println("Encrypted message:", encrypted)
decrypted := enigmaDecrypt(encrypted, shift)
fmt.Println("Decrypted message:", decrypted)
}
The real Enigma had three or four rotors, a reflector, and a plugboard. Ours is the “break the code at home” version, but the spirit’s the same!
Modern Cryptography: Today’s Code Heroes
Things are a little more scientific these days—mathematicians and computers rule the cryptographic universe. Algorithms protect your data everywhere, from banking to messaging.
With Go, you can write your own crypto in just a few lines. Here’s a quick example using AES encryption:
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"io"
)
// Short AES encryption function
func encryptAES(key, plaintext []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
ciphertext := make([]byte, aes.BlockSize+len(plaintext))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
stream := cipher.NewCFBEncrypter(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext)
return ciphertext, nil
}
(Don’t forget your key! Lose it, and even you can’t decrypt your stuff!)
The Enigma machine showed the world: codes can change history. Who knows—maybe one day you’ll write your own “enigma” and save the world (or at least your breakfast group) with secret messages!
Remember: cryptography can save lives… or just make you look incredibly cool.
Playing with code, testing new ciphers, and sharing secrets is always a good time!
Alan Turing (1912-1954) was a pioneering British mathematician, cryptanalyst, and computer scientist. He is best known for his crucial role in breaking the German Enigma code during World War II at Bletchley Park, a breakthrough that helped shorten the war and save countless lives.
Turing laid the foundations of modern computer science with his concept of the “Turing machine” and introduced the idea of algorithms and computation. He also proposed the “Turing Test” as a way to determine if a machine can exhibit intelligent behavior.
Despite his contributions, Turing was prosecuted for his homosexuality, leading to his tragic early death in 1954. Today, he is celebrated as a hero and a father of computer science.

Sources & Recommended Reading:
- Simon Singh, The Code Book
- Alan Turing Wiki: https://tr.wikipedia.org/wiki/Alan_Turing
- Turing’s Enigma story: Wikipedia - Enigma Machine
- Go cryptography docs: Go crypto package
At the end of this page, you can also find the Turkish presentation I prepared for our company on “Enigma and Cryptography.”
This presentation covers the historical significance of the Enigma machine, the fundamentals of cryptography, and modern encryption techniques in detail.
If you are interested, feel free to review the presentation or reach out to me with any questions.