diff --git a/.idea/enigmaMachine.iml b/.idea/enigmaMachine.iml index ebe9288..ddd0a9c 100644 --- a/.idea/enigmaMachine.iml +++ b/.idea/enigmaMachine.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 33d9f86..cae906c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 285d240..29e2404 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,39 @@ # Enigma Machine -Recreates the functionality of the Enigma Machine from World War II. Mainly just an exercise in Python. +I still sort of remember being a kid and discovering that you could make a map of letters and from that have a simple +encoding mechanism. + +For example (in the table shown below), the letter A would be encoded as M, B as N, C as O, and so on. + +| Letter | Encoding | +|--------|----------| +| A | M | +| B | N | +| C | O | +| ... | ... | +| Z | L | + +This is a [substitution cipher](https://en.wikipedia.org/wiki/Substitution_cipher) and is pretty simplistic by modern standards, but as a kid I thought it was cool [AF](https://www.howtogeek.com/711826/what-does-af-mean/). + +One evening I was watching a video on YouTube about the Enigma Machine. It piqued my interest and I decided to make +something in Python to recreate the functionality. + +## History +> The Enigma machine is a cipher device developed and used in the early- to mid-20th century to protect commercial, +> diplomatic, and military communication. It was employed extensively by Nazi Germany during World War II, in all +> branches of the German military. The Enigma machine was considered so secure that it was used to encipher the most +> top-secret messages. +> +> The Enigma has an electromechanical rotor mechanism that scrambles the 26 letters of the alphabet. In typical use, one +> person enters text on the Enigma's keyboard and another person writes down which of the 26 lights above the keyboard +> illuminated at each key press. If plaintext is entered, the illuminated letters are the ciphertext. Entering +> ciphertext transforms it back into readable plaintext. The rotor mechanism changes the electrical connections between +> the keys and the lights with each keypress. +> +> -- [Wikipedia](https://en.wikipedia.org/wiki/Enigma_machine) ## Usage `uv run main.py "[message]" e|d [int]` - Where: - __"[message]"__ is the message to be encrypted/decrypted. Should be in quotes. - __e|d__ is the direction of the message (encrypt or decrypt). diff --git a/main.py b/main.py index ca69aed..2c2b4f4 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,7 @@ def main(): print("Invalid iterations value.") sys.exit(1) + # todo this does not run because of the above check if int(sys.argv[3]) == 0: iterations = 3 else: @@ -28,6 +29,7 @@ def main(): seed_values: list[int] = [] if sys.argv[2] == "e": + # TODO allow flag to specify a file vs. always creating a new one with open("seeds.txt", "w") as f: for iteration in range(0, iterations): random.seed(time.time())