<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy" -->

---
title: Building My Own Enigma Machine Simulator | daily.dev
description: A developer built a full-stack Enigma machine simulator using React, TypeScript, and Express.js with MongoDB. The project recreates the historic WWII...
canonical: https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building My Own Enigma Machine Simulator | daily.dev
og:description: A developer built a full-stack Enigma machine simulator using React, TypeScript, and Express.js with MongoDB. The project recreates the historic WWII...
og:url: https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy
og:image: https://api.daily.dev/og/posts/WWnI8vNpY.png
og:image:alt: Building My Own Enigma Machine Simulator
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building My Own Enigma Machine Simulator

**[Mohd Shamoon](https://daily.dev/sources/ykcpdpgnsaluc6bvz8kfk)** · [@mohdshamoon04](https://daily.dev/mohdshamoon04) · 5 min read · 64 upvotes · 6 comments

## Summary

A developer built a full-stack Enigma machine simulator using React, TypeScript, and Express.js with MongoDB. The project recreates the historic WWII encryption device with features like symmetric encryption/decryption, custom machine generation via seed and email, and an interactive UI with rotor and plugboard simulation. The implementation includes both frontend visualization and backend API handling, demonstrating cryptographic principles while serving as an educational tool.

## Content

# **Building My Own Enigma Machine Simulator**

## 0. TL;DR
I built a full-stack **Enigma machine simulator** inspired by the historic WWII encryption device.

* **Frontend:** React, TypeScript, Tailwind CSS, Jest
* **Backend:** Express.js (TypeScript), MongoDB, Mongoose
* Features symmetric encryption/decryption, custom machine generation via seed + email, and an interactive UI with rotor and plugboard simulation.
* Learned a lot about dynamic rendering, SVG manipulation, and state management.
* [GitHub Repo](https://github.com/MOHD-SHAMOON-04/EnigmaMach) | [Live Demo](https://enigma-shamoon-04.netlify.app/)

---
## 1. Introduction
**Enigma**: a person, **thing**, or situation that is difficult to understand - and that’s exactly what we’re going to discuss.

Over the past few days, I have been working on a project that’s both a tribute to history and a fun technical challenge - an **Enigma machine simulator**.

As someone fascinated by history, I’ve always admired how, long before computers existed, people engineered incredibly sophisticated cryptographic systems using nothing more than electricity and precision mechanical parts. The Enigma machine is one of the most iconic examples.

![Military Model Enigma I encryption machine, used from 1930, on display at Museo della Scienza e della Tecnologia "Leonardo da Vinci" - Photo by Alessandro Nassiri, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=47910919](https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Enigma_%28crittografia%29_-_Museo_scienza_e_tecnologia_Milano.jpg/800px-Enigma_%28crittografia%29_-_Museo_scienza_e_tecnologia_Milano.jpg)

---
## 2. Historical Context
The **Enigma machine** was an encryption device used by the Germans during World War II to secure military communications. It relied on a series of rotors, plugboard connections, and a reflector to scramble messages into seemingly unreadable text.

![Diagram showing the scrambling process of Enigma’s rotors - Illustration by MesserWoland, based on original work by Matt Crypto, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=1794494](https://media.daily.dev/image/upload/s--T2Lyu_SL--/f_auto/v1755346165/ugc/content_f10d5c92-6e5b-4429-abb8-21ecd637817f?_a=BAMClqZW0)

Breaking Enigma was a monumental task that required not only brilliant minds but also ingenuity in engineering. **Alan Turing** and his team at Bletchley Park, building on the earlier work of **Polish cryptographers** and their invention of the *bomba* machine, ultimately cracked the code a breakthrough that significantly shortened the war.

![Black-and-white wartime photograph of a Bletchley Park Bombe decryption machine in operation - Public Domain, https://commons.wikimedia.org/w/index.php?curid=72819587](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Wartime_picture_of_a_Bletchley_Park_Bombe.jpg/800px-Wartime_picture_of_a_Bletchley_Park_Bombe.jpg)

---
## 3. Project Motivation
I’ve always been amazed by the mix of engineering, mathematics, and human determination that went into the Enigma story. So, I decided to **recreate the machine in code**, both as a way to deepen my programming skills and to better appreciate the cryptographic principles behind it.

---
## 4. The Algorithm
One of the most elegant aspects of the Enigma is that it uses **symmetric encryption** - meaning the same process is used for both encryption and decryption.
Example: If you type `A` with rotor settings `[7:3:6]` and the machine outputs `H`, then simply resetting the machine to `[7:3:6]` and typing `H` will give you back `A`.

### 4.1 The Rotors, Reflector & Basic Flow
The **rotors** are the real stars of the show - they scramble your input letters using internal wiring.
Here’s the journey of a character:

**Forward Pass**
1. The typed letter enters **Rotor I**, where it’s mapped to a new letter (let’s call it `char°`).
2. This `char°` then enters **Rotor II**, producing `char°°`.
3. Then through **Rotor III**, resulting in `char°°°`.

**The Reflector**
The reflector takes this `char°°°` and maps it to another letter `REF(char°°°)`. This mapping is also one-to-one, meaning no letter ever maps to itself here.

**Backward Pass**
`REF(char°°°)` now travels back through the rotors in reverse order - but this time the mapping is reversed. After passing through all three rotors again, we get `REF(char°°°)°°°` - the raw encrypted output.

At this stage, the machine is symmetric but **not secure by modern cryptographic standards**.
With only three rotors, there are `26 × 26 × 26 = 17,576` starting positions. That’s a joke by today’s brute-force standards - you could crack it in milliseconds with a modern computer.

### 4.2 The Plugboard - Supercharging the Encryption
The **plugboard** sits between the keyboard and Rotor I.

* When you type a letter, it first goes through the plugboard and **may be** swapped with another letter.
* After the backward pass through the rotors, the letter passes through the plugboard again before appearing on the lampboard.

This simple addition **skyrockets the number of possible configurations**:  

1. **Plugboard swaps**: In the real Enigma, you could connect up to 10 letter pairs, giving `(26!) / (6! x 10! x 2^10) ≈ 150,738,274,937,250` possible wirings.  
2. **Rotor positions**: `17,576` possible starting points.  
3. **Rotor choice**: If you allowed 3 rotors out of 5, there are `60` possible selections.  

Total possible configurations: `17,576 x 150,738,274,937,250 x 60`  

Which equals: **158,962,555,217,826,360,000 combinations** - enough to keep early 20th-century cryptanalysts up at night. But with today’s computing power, this is still solvable - though orders of magnitude harder than without the plugboard.

---
## 5. Tech Stack & Implementation
I built the simulator using the following technologies:

### Frontend:
* **React** - to structure and render the UI.
* **TypeScript** - for type safety and clarity in the core encryption logic.
* **Jest** - to test the core `EnigmaEnigne`.
* **Tailwind CSS** - to style components quickly and cleanly.

### Backend:
* **Express.js** with **TypeScript** - to handle API requests and business logic.
* **Mongoose** - as the ODM for working with MongoDB.
* **MongoDB** - to store user configurations and generated machine data.

The simulator includes both encryption and decryption logic (since Enigma is symmetric, the same configuration can reverse the encryption).

A standout feature I added is **custom machine generation**. Users can generate their own personalized machine by providing a seed and email. The app uses these inputs to create a unique configuration, which can be sent directly to them via an email.

![Screenshot of the Enigma machine simulator UI, showing rotor configuration and plugboard interface](https://media.daily.dev/image/upload/s--F-Bz68CR--/f_auto/v1755256262/ugc/content_bc14925e-8c0e-44cc-95a2-dc1bf6a26faa?_a=BAMClqZW0)

---
## 6. Challenges & Learnings
The most difficult part for me was **UI design**. It’s not my strongest area, and I tried to avoid relying on AI tools as much as possible though I did use them in a few spots.

This project also helped me:
* Refresh my **React** and **Tailwind CSS** knowledge.
* Learn new techniques for **dynamic rendering** (like overlapping SVGs for the plugboard).
* Improve my **state management** skills.

On the backend side, everything went smoothly from database integration to deployment.

![Initial plugboard layout with no scrambling applied](https://media.daily.dev/image/upload/s--h6gROwFx--/f_auto/v1755256268/ugc/content_d8aa5c10-d90c-46cb-9596-120e197efc97?_a=BAMClqZW0)

![Plugboard layout after scrambling applied, showing altered connections](https://media.daily.dev/image/upload/s---40K1vJK--/f_auto/v1755256279/ugc/content_b7eb9528-f42d-43c1-b672-d3ee2e32479c?_a=BAMClqZW0)

---
## 7. Results
The final simulator lets users experience the process of encrypting and decrypting messages just like an original Enigma machine would (minus the physical clicking of rotors, unfortunately).

The UI visually represents the machine’s key components, making it more than just functional it’s also **Educational**.

![Encrypted message output generated by the Enigma machine simulator](https://media.daily.dev/image/upload/s--WQm1t36k--/f_auto/v1755256273/ugc/content_8ff32693-eb62-45d1-86fe-7afd79c669ed?_a=BAMClqZW0)

---
## 8. How to Use
* Try the **live demo** to experience encryption in real time.
* Enter your message, adjust machine settings, and see the encrypted output.
* Use the same settings to decrypt and retrieve the original text.

![Step-by-step usage guide for the Enigma machine simulator](https://media.daily.dev/image/upload/s--W5shGabk--/f_auto/v1755256285/ugc/content_a2404341-9d80-476c-a21c-7ddb92f29059?_a=BAMClqZW0)

---
## 9. Links
* **GitHub Repo:** [MOHD-SHAMOON-04/EnigmaMach](https://github.com/MOHD-SHAMOON-04/EnigmaMach) *(Code)*
* **Live Demo:** [enigma-shamoon-04](https://enigma-shamoon-04.netlify.app/) *(Web App)*
* **Further Reading and Resources:**
  * [Enigma Machine - Numberphile](https://www.youtube.com/watch?v=G2_Q9FoD-oQ) *(Video)*
  * [Brilliant.org: Enigma Machine](https://brilliant.org/wiki/enigma-machine/) *(History)*
  * [Wikipedia.org: Enigma Machine](https://en.wikipedia.org/wiki/Enigma_machine) *(Reference)*

---
## 10. Future Improvements
Some ideas I’m considering for future updates:

* **Saving & sharing configurations** Allow users to export an encrypted message as a link.
* A **visual animation** of the encryption process explained in ([4. The algorithm](#4-the-algorithm)) in real time

---
If you enjoy cryptography, history, or just love challenging programming projects, I hope you’ll check out the simulator and maybe even spin up your own custom Enigma.

---

#cryptography #history-of-computing #enigma-machine #alan-turing #typescript #react #tailwindcss #expressjs #mongodb #javascript #cybersecurity #project-showcase #opensource

## Community discussion

Top comments from developers on daily.dev.

**@aatirjawed** · 1 upvotes

> Great project simulating something from real world which had a great impact on history.
> It's just crazy how people at those times developed such intricate methods and then others developed ways to crack them.

**@navystudent2893** · 1 upvotes

> Thats brilliant! I specially like the part where we can use our own seed to create a new machine, very well done.

**@jodc** · 1 upvotes

> Fascinating work, and looks great! a tip since you said you struggle with design, check out design theory (not tech related but design in itself). There is usually an overlap between the two especially for color theory typography and other items!

---

Tags: [#react](https://daily.dev/tags/react), [#typescript](https://daily.dev/tags/typescript), [#mongodb](https://daily.dev/tags/mongodb), [#cryptography](https://daily.dev/tags/cryptography), [#express](https://daily.dev/tags/express)

[View this post on daily.dev](https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy","headline":"Building My Own Enigma Machine Simulator","text":"A developer built a full-stack Enigma machine simulator using React, TypeScript, and Express.js with MongoDB. The project recreates the historic WWII encryption device with features like symmetric encryption/decryption, custom machine generation via seed and email, and an interactive UI with rotor and plugboard simulation. The implementation includes both frontend visualization and backend API handling, demonstrating cryptographic principles while serving as an educational tool.","url":"https://daily.dev/posts/building-my-own-enigma-machine-simulator-wwni8vnpy","datePublished":"2025-08-15T11:53:16.588Z","dateModified":"2025-09-10T15:05:14.905Z","author":{"@type":"Person","name":"Mohd Shamoon","url":"https://daily.dev/mohdshamoon04","image":"https://lh3.googleusercontent.com/a/ACg8ocIT-17aRBv4H1Em9-R-jcklotCVMTs1ZfPiOPV-e-0m03tW7w=s96-c","description":"Software Developer || ML Engineer","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":640}},"image":"https://media.daily.dev/image/upload/s--b1dJsr4u--/f_auto/v1755258796/posts/WWnI8vNpY?_a=BAMClqZW0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":64},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":6}],"comment":[{"@type":"Comment","text":"Great project simulating something from real world which had a great impact on history.\nIt’s just crazy how people at those times developed such intricate methods and then others developed ways to crack them.","datePublished":"2025-08-15T12:11:09.325Z","url":"https://daily.dev/posts/WWnI8vNpY#c-HaAqtlaGe","author":{"@type":"Person","name":"Aatir Jawed","url":"https://daily.dev/aatirjawed","image":"https://lh3.googleusercontent.com/a/ACg8ocLtCvNKUAfXJjc1KwE86PN9Luu8a8ujenVFVOu_YRUzqdsDJ8s=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Thats brilliant! I specially like the part where we can use our own seed to create a new machine, very well done.","datePublished":"2025-08-15T12:39:40.116Z","url":"https://daily.dev/posts/WWnI8vNpY#c-8K2GT5RG8","author":{"@type":"Person","name":"Maaz","url":"https://daily.dev/navystudent2893","image":"https://avatars.githubusercontent.com/u/147193589?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Fascinating work, and looks great! a tip since you said you struggle with design, check out design theory (not tech related but design in itself). There is usually an overlap between the two especially for color theory typography and other items!","datePublished":"2025-08-16T06:05:28.922Z","url":"https://daily.dev/posts/WWnI8vNpY#c-cpAvvfLtz","author":{"@type":"Person","name":"Josef Röyem","url":"https://daily.dev/jodc","image":"https://avatars.githubusercontent.com/u/140382311?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/ykcpdpgnsaluc6bvz8kfk","name":"Mohd Shamoon"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Mohd Shamoon","item":"https://daily.dev/sources/ykcpdpgnsaluc6bvz8kfk"},{"@type":"ListItem","position":3,"name":"Building My Own Enigma Machine Simulator"}]}
```

