Skip to content

Instantly share code, notes, and snippets.

@jvarho
jvarho / enigma.py
Last active June 23, 2016 10:15
Enigma machine emulator, written in Python
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
class Rotor():
perms = []
turnover_position = ''
position = 'A'
def __init__(self, perms, turnover_position, ring_setting):
i = alphabet.index(ring_setting)
perms = perms[i:] + perms[:i]
self.perms = [c for c in perms]