Electronics Club – IIT Kanpur
The project is developed both as a software simulator and a hardware replica, offering insight into classical encryption systems and their implementation.
Mentors :
Kshitij Bhardwaj
Tanvi Manhas
Kamal Jaiswal
Shrasti Dwivedi
A simple substitution cipher where each letter in the plaintext is shifted by a fixed number (key) of positions.
Drawbacks:
- Only 25 possible shifts – vulnerable to brute-force
- Frequency analysis is easy due to unchanged letter frequency
- Very small key space
- Limited to alphabetical input
A substitution cipher using the formula:
E(x) = (a·x + b) mod 26
, where x
is the letter index.
Decryption:
D(x) = a⁻¹(x − b) mod 26
Example (a = 5, b = 8):
HELLO → RCLLA
Drawbacks:
- Limited key space
- Vulnerable to frequency analysis
- Susceptible to known-plaintext attacks
A complex electro-mechanical cipher machine from WWII. Encryption varies with each keystroke due to rotor advancement.
Components:
- Plugboard: Swaps letters
- Rotors: Substitute and rotate with each keypress
- Reflector: Sends signal back through rotors
- Rotor Stepping: Changes encryption path dynamically
- Reversed Path: Output reprocessed through plugboard
Advantages:
- Dynamic substitution
- Over 10¹¹⁴ possible configurations
- Resistant to frequency analysis
- Full Enigma simulation: plugboard, rotors, reflector
- User-configurable settings: rotor types, positions, plugboard
- GUI implementation using JavaScript and PySimpleGUI
- Support for encryption/decryption with the same settings
- Import/export of configurations and messages
- Modular, object-oriented codebase
- Replica using Arduino Nano/Uno
- Pushbuttons or keyboard for input
- Rotor logic with LEDs and motors
- LCD output to display ciphertext
- Manual rotor control using rotary encoders
- Functional plugboard simulated via switches or digital interface
Initial inspiration came from a Stanford assignment on simulating the Enigma Machine.
Assignment Link:
https://web.stanford.edu/class/cs106j/handouts/37-Assignment5.pdf
- Receives data from PC via serial
- Executes encryption
- Displays ciphertext on 16x2 LCD
- Uses rotary encoder for real-time rotor adjustments
- I2C/Parallel interface
- Displays rotor positions and encrypted output
- Feedback for user actions
- Rotate to change rotor offsets
- Push to switch active rotor
- Updates displayed configuration
To be defined depending on system design
Includes wiring diagrams and PCB schematics for:
- Rotary Encoder
- LCD
- Arduino Connections
What are Protothreads?
Lightweight, stackless cooperative threads (coroutines) for memory-limited systems.
Thread SerialInputThread:
PT_BEGIN()
loop forever:
PT_WAIT_UNTIL(serialAvailable())
message = readSerial()
parseMessage(message)
PT_END()
Thread EncryptionThread:
PT_BEGIN()
loop forever:
PT_WAIT_UNTIL(newMessageAvailable)
for each letter in message:
StepRotors()
encrypted = EncryptLetter(letter, rotorPositions, plugboard)
append encrypted to output
PT_END()
Thread DisplayThread:
PT_BEGIN()
loop forever:
updateLCD(output)
delay(100 ms)
PT_END()
This section covers the core Enigma encryption process implemented in C.
Includes:
- Fixed rotor and reflector wirings
- Rotor stepping mechanism
- Plugboard and sketcherboard support
- Letter-to-index conversions
- Encryption buffer handling
Function EncryptLetter(inputLetter, rotorPositions, plugboardMap):
// Step 1: Plugboard
letter = plugboardMap[inputLetter]
// Step 2: Forward through rotors
for rotor in rotors (from right to left):
index = (alphabetIndex(letter) + rotor.position) % 26
letter = rotor.mapping[index]
// Step 3: Reflector
letter = reflectorMap[letter]
// Step 4: Reverse through rotors
for rotor in rotors (from left to right):
index = rotor.mapping.index(letter)
letter = alphabet[(index - rotor.position + 26) % 26]
// Step 5: Plugboard again
letter = plugboardMap[letter]
return letter
Function StepRotors():
// Rightmost rotor always steps
rotor[0].position += 1
if rotor[0].position == notch[0]:
rotor[1].position += 1
if rotor[1].position == notch[1]:
rotor[2].position += 1