This is 3 rotors enigma simulater
3ローターのエニグマシミュレータです。 日本語解説は、こちらから
In Python:
python -m pip install git+https://github.com/kazumamatsu/enigma_sim.git
In IPython:
!pip install git+https://github.com/kazumamatsu/enigma_sim.git
import enigma
config = list("AAA")
E = enigma.enigma(config[0], config[1], config[2], seed = 100)
text = list(str.upper(input()))
code = []
for t in text:
code.append(E.typing(t))
print(text)
print(code)
input:
JAPAN
output:
>>> JAPAN
>>> ['J', 'A', 'P', 'A', 'N']
>>> ['W', 'U', 'Z', 'H', 'W']
E = enigma.enigma(config[0], config[1], config[2], seed = 100)
text = list(str.upper(input()))
code = []
for t in text:
code.append(E.typing(t))
E.dec_print(ptype = 0)
print(text)
print(code)
output:
>>> JAPAN
>>> J -> Y -> H -> Q -> K -> G -> Z -> L -> W
>>> A -> B -> P -> K -> D -> R -> J -> O -> U
>>> P -> E -> N -> Z -> A -> M -> E -> B -> Z
>>> A -> H -> M -> H -> F -> A -> O -> I -> H
>>> N -> E -> P -> K -> D -> R -> J -> R -> W
>>> ['J', 'A', 'P', 'A', 'N']
>>> ['W', 'U', 'Z', 'H', 'W']
E = enigma.enigma(config[0], config[1], config[2], seed = 100)
decode = []
for t in code:
decode.append(E.typing(t))
print(decode)
output:
>>> ['J', 'A', 'P', 'A', 'N']
E.dec_print(ptype = 0)
>>> J -> Y -> H -> Q -> K -> G -> Z -> L -> W
E.dec_print(ptype = 1)
>>> J -> W