Updated README.

This commit is contained in:
Kenn Kitchen
2025-11-02 18:56:31 -05:00
parent a30e010c5c
commit 0c795969a1
4 changed files with 35 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" /> <excludeFolder url="file://$MODULE_DIR$/.venv" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.13 (enigmaMachine)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="uv (enigmaMachine)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

2
.idea/misc.xml generated
View File

@@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Python 3.13 (enigmaMachine)" /> <option name="sdkName" value="Python 3.13 (enigmaMachine)" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13 (enigmaMachine)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="uv (enigmaMachine)" project-jdk-type="Python SDK" />
</project> </project>

View File

@@ -1,10 +1,39 @@
# Enigma Machine # 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 ## Usage
`uv run main.py "[message]" e|d [int]` `uv run main.py "[message]" e|d [int]`
Where: Where:
- __"[message]"__ is the message to be encrypted/decrypted. Should be in quotes. - __"[message]"__ is the message to be encrypted/decrypted. Should be in quotes.
- __e|d__ is the direction of the message (encrypt or decrypt). - __e|d__ is the direction of the message (encrypt or decrypt).

View File

@@ -19,6 +19,7 @@ def main():
print("Invalid iterations value.") print("Invalid iterations value.")
sys.exit(1) sys.exit(1)
# todo this does not run because of the above check
if int(sys.argv[3]) == 0: if int(sys.argv[3]) == 0:
iterations = 3 iterations = 3
else: else:
@@ -28,6 +29,7 @@ def main():
seed_values: list[int] = [] seed_values: list[int] = []
if sys.argv[2] == "e": 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: with open("seeds.txt", "w") as f:
for iteration in range(0, iterations): for iteration in range(0, iterations):
random.seed(time.time()) random.seed(time.time())