Skip to content

kazumamatsu/enigma_sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Enigma simulater

Overview

This is 3 rotors enigma simulater
3ローターのエニグマシミュレータです。 日本語解説は、こちらから

Quickstart

Installation

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

Using enigma_simulater in a Python script

Import module

import enigma

Setting config

config = list("AAA")

Encryption

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']

If you want to display the process

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']

Decoding

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']

Print option

E.dec_print(ptype = 0)
>>> J -> Y -> H -> Q -> K -> G -> Z -> L -> W
E.dec_print(ptype = 1)
>>> J -> W

About

This is 3 rotors enigma simulater

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages