Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/panagiotiskots/enigma-machine-simulator

A C-based simulation of the Enigma machine encryption process
https://github.com/panagiotiskots/enigma-machine-simulator

c cryptography encryption encryption-algorithms encryption-decryption enigma enigma-machine enigma-simulator history

Last synced: 22 days ago
JSON representation

A C-based simulation of the Enigma machine encryption process

Awesome Lists containing this project

README

        

# ๐Ÿ›ก๏ธ Enigma Machine Simulator

A C-based simulation of the Enigma machine encryption.

The Enigma machine is one of the most famous encryption devices in history, used extensively by Nazi Germany during World War II. It became a symbol of cryptographic warfare due to the significant efforts made by the Allies to crack its codes.

---

## ๐Ÿ› ๏ธ Early Development

### ๐Ÿ”จ Invention

- **Inventor**: German engineer Arthur Scherbius.
- **Year**: Patented in 1918, shortly after World War I.
- **Purpose**: Initially designed for commercial use to secure corporate communications.

### ๐Ÿ’ผ Commercial Models

- **1920s**: Early commercial Enigma models marketed to banks and businesses.
- These models werenโ€™t commercially successful but demonstrated the potential of mechanical encryption devices.

---

## โš”๏ธ Military Adoption

### ๐Ÿช– German Military Interest

- By the **late 1920s** and **early 1930s**, the German military recognized Enigmaโ€™s potential for secure communications.
- The military **modified** and enhanced the machine to increase security, adding:
- Additional **rotors**.
- The **plugboard** for added complexity.

### ๐ŸŒ Usage During WWII

- Enigma became the **primary encryption device** for the German **Army**, **Navy**, **Air Force**, and intelligence services.
- It was believed to be **unbreakable** due to its **complex encryption methods**.

## ๐Ÿ”ง The Enigma Machine Design

| **Component** | **Description** |
|-------------------------------|-------------------------------------------------------------------------------------|
| โš™๏ธ **Rotors (Wheels)** | Rotating disks that scrambled the input letters. |
| ๐Ÿ”„ **Reflector (Umkehrwalze)** | Reflected signals back through the rotors, ensuring bidirectional encryption. |
| ๐Ÿ”Œ **Plugboard (Steckerbrett)** | Allowed additional letter substitutions for extra complexity. |
| โŒจ๏ธ **Keyboard** | Used by the operator to type plaintext messages. |
| ๐Ÿ’ก **Lampboard** | Lit up the encrypted letters in response to each keypress. |

### โš™๏ธ Operation

- Each keypress caused the rotors to move, altering the encryption path for each letter.
- The plugboard provided an additional layer of substitution before and after the signal passed through the rotors.

---

## ๐Ÿง  Breaking the Enigma

### ๐Ÿ‡ต๐Ÿ‡ฑ Polish Efforts

- The first major breakthroughs in cracking Enigma came from **Polish cryptanalysts** in the 1930s.
- Mathematicians **Marian Rejewski**, **Jerzy Rรณลผycki**, and **Henryk Zygalski** applied mathematical techniques to study the Enigmaโ€™s structure.
- They built early mechanical devices, such as the "**bombe**", to help decipher Enigma messages.

### ๐Ÿ‡ฌ๐Ÿ‡ง Transfer to the Allies

- In **1939**, just before World War II, Polish cryptanalysts shared their knowledge with **British** and **French intelligence services**.
- This transfer was crucial for further Allied code-breaking efforts.

### ๐Ÿฐ Bletchley Park

- During World War II, **Bletchley Park** became the hub of Allied cryptanalysis.
- **Alan Turing**, along with **Gordon Welchman** and others, developed advanced versions of the **bombe** machine to automate the decryption of Enigma-encoded messages.

### ๐Ÿ•ต๏ธ Impact on the War

- The successful decryption of Enigma-encoded messages, known as "**Ultra**" intelligence, gave the Allies insight into German military operations.
- Historians widely believe that Ultra **shortened the war** and saved countless lives.

## ๐Ÿ“œ Post-War and Legacy

### ๐Ÿ”’ Secrecy and Declassification

- The work at **Bletchley Park** remained highly classified until the **1970s**.
- The full extent of the Enigma and code-breaking efforts was not revealed to the public until much later.

### ๐Ÿ›๏ธ Historical Significance

- The **Enigma machine** has become an iconic symbol in the history of **cryptography** and **warfare**.
- Its story has been the subject of numerous **books**, **documentaries**, and **films**, showcasing the intersection of **technology**, **mathematics**, and **military intelligence**.

### ๐Ÿ“š Additional Resources

- Learn more about **Alan Turing** and the efforts to crack the Enigma code: [**Bletchley Park**](https://bletchleypark.org.uk)
- For an in-depth look at the mathematics behind the Enigma: [**The Bombe Machine**](https://en.wikipedia.org/wiki/Bombe)

---

The **Enigma machine** remains a monumental feat of encryption technology and a critical turning point in the history of cryptography. Its story not only highlights the challenges of secure communications but also the power of human ingenuity in solving complex problems.

# The Programm

A **C-based simulation** of the historic Enigma machine, demonstrating the encryption process used in this iconic ciphering device. The simulator replicates the step-by-step mechanics of the original machine, allowing users to follow each encryption stage in detail.

## ๐Ÿ”‘ Features

- **Full Enigma encryption simulation** including rotor and reflector behavior.
- **Detailed step-by-step output**, displaying the encryption process for each letter.
- **Customizable rotor positions** for flexible configurations and experimentation.
- Easy-to-follow structure with **explanations of each encryption stage** in the output.

## ๐Ÿ› ๏ธ Installation

1. **Clone the repository**:

git clone https://github.com/PanagiotisKots/Enigma-Machine-Simulator.git

Navigate to the project directory:

cd Enigma-Machine-Simulator

Compile the code:

gcc -o enigma Enigma.c

๐Ÿš€ Usage

To run the Enigma machine simulation:

./enigma.exe

The program will prompt you to enter a message, after which it will display a step-by-step encryption process and the final encrypted message.
โš™๏ธ How It Works
Key Components

Rotors: Rotating disks that map input letters to other letters. Their positions shift with each key press, dynamically changing the encryption path.
Reflector: Reflects the signal back through the rotors, adding a second encryption pass.
Plugboard: (Not implemented in this version) Would allow additional letter substitutions for even greater complexity.

Encryption Process

Forward Pass Through Rotors: Each input letter is passed through the sequence of rotors, with the rotor positions shifting based on prior encryptions.
Reflection: The letter is then reflected back through the rotors, further scrambling the signal.
Backward Pass Through Rotors: The reflected letter is passed again through the rotors in reverse order.
Rotor Stepping: After each letter, the rotors step, changing their positions and modifying the encryption for the next input.

Example Encryption Output

The program prints out detailed steps for each character's encryption:

Encrypting character: A
Initial Rotor Positions: [0, 0, 0]
After Rotor 1: E
After Rotor 2: K
After Rotor 3: Z
After Reflector: R
Back through Rotor 3: X
Back through Rotor 2: P
Back through Rotor 1: G
Encrypted character: G

๐Ÿ”„ Rotor Positioning

The rotor stepping mechanism advances the rotors after each key press, creating a different encryption pattern for each character. You can reset the rotor positions manually or modify them for specific use cases, providing flexibility in your encryption tests.
๐Ÿง  Customization

You can easily customize the rotor configurations and starting positions by modifying the code, making it possible to explore different encryption patterns and behaviors.

| ๐Ÿ› ๏ธ **Feature** | ๐Ÿ’ก **Difficulty Level** | ๐Ÿ“ˆ **Complexity** | ๐Ÿง  **Breaking Difficulty** |
|-----------------------------|-------------------------|----------------------|----------------------------|
| โš™๏ธ **Rotors Mechanism** | ๐ŸŸข Basic Implementation | ๐Ÿ”น Moderate | ๐ŸŸก Medium |
| ๐Ÿ”„ **Rotor Stepping** | ๐ŸŸก Intermediate | ๐Ÿ”ธ High | ๐ŸŸ  Challenging |
| ๐Ÿ”Œ **Plugboard (Steckerbrett)** | ๐Ÿ”ด Advanced | ๐Ÿ”ป Very High | ๐Ÿ”ด High |
| ๐Ÿ” **Reflector (Umkehrwalze)** | ๐ŸŸข Basic Implementation | ๐Ÿ”น Moderate | ๐ŸŸ  Challenging |
| ๐Ÿ” **Encryption Process** | ๐ŸŸก Intermediate | ๐Ÿ”ธ High | ๐ŸŸ  Challenging |
| ๐Ÿงฎ **Mathematical Model** | ๐Ÿ”ด Advanced | ๐Ÿ”ป Very High | ๐Ÿ”ด High |
| ๐Ÿ” **Overall Decryption** | ๐Ÿ”ด Very Advanced | ๐Ÿ”ป Complex | ๐Ÿ”ด Very High |

| ๐Ÿ› ๏ธ **Component** | ๐Ÿ“ธ **Image** | ๐Ÿ“„ **Description** |
|-----------------------------|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| โš™๏ธ **Enigma Machine** | ![Enigma Machine](https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Enigma_%28crittografia%29_-_Museo_scienza_e_tecnologia_Milano.jpg/220px-Enigma_%28crittografia%29_-_Museo_scienza_e_tecnologia_Milano.jpg) | The full Enigma machine, showing the rotors, reflector, and plugboard. |
| ๐Ÿ”„ **Rotors** | ![Rotors](https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Enigma_rotors_with_alphabet_rings.jpg/220px-Enigma_rotors_with_alphabet_rings.jpg) | The rotating disks (rotors) that scramble the input letters. |
| ๐Ÿ”Œ **Plugboard (Steckerbrett)** | ![Plugboard](https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Enigma-plugboard.jpg/220px-Enigma-plugboard.jpg) | The plugboard used for additional letter pair substitutions. |
| ๐Ÿ” **Reflector (Umkehrwalze)** | ![Reflector](https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Enigma_insides.agr.jpg/220px-Enigma_insides.agr.jpg) | The reflector that sends the electrical signal back through the rotors. |