Skip to main content

Enigma Machine Encryption

Project description

This is Project Encryption, which allows you to encrypt any strings using the Enigma Machine concepts. This module can only encrypt strings as of now, encryption for numbers and symbols will come in the future updates.

Encryption

Concept In order to Encrypt a string, you would need three rotor layouts. A rotor layout is a list consisting 26 numbers, ranging from 1-26, with each number representing a letter in the alphabet. For example, in [1,2,3,4,5,...], 1 would equal A, and 2 would equal B and so on. You can change the order of the numbers to enhance the description. For example: [1,26,3,9,11,20...] If you do not want to make your own list, there is an autogenerate option to generate a random rotor layout and random rotor position (will be explained later).

Example

from EnigmaEncryption import *

EnigmaMachine = EnigmaAssembly(autogenerate=True)
encryptedText = EnigmaMachine.Encrypt("Example string getting encrypted")
print(encryptedText)

Output (Varies and is different each time you run it) An example of the output might be:

Padzkfj avugmg rgieasa mimknkrss

Decryption

Concept In order to Encrypt a string, you would need the three rotor layouts and the initial position for the rotors of the machine. The starting position of the rotors can affect the encoding even with the same set of rotor layouts.

You can get the rotations and the rotor layouts using:

from EnigmaEncryption import *

EnigmaMachine = EnigmaAssembly(autogenerate=True)

Rotations = EnigmaMachine.getRotations() //Gets the rotations of the three rotors in a dictionary. For example, Rotations["Rotor1"] will get the rotation of Rotor 1, Rotations["Rotor2"] will get rotations of Rotor 2.

Keys = EnigmaMachine.getKeys() //Gets the rotor layouts in a dictionary. For example, Rotations["Rotor1"] will get the layout of Rotor 1, Rotations["Rotor2"] will get layout of Rotor 2.

To decrypt the message, you have to input the encrypted text, rotations and the layouts like the following code:

from EnigmaEncryption import *

EnigmaMachine = EnigmaAssembly(autogenerate=True)
Rotations = EnigmaMachine.getRotations()
Keys = EnigmaMachine.getKeys()
Rotor1 = Rotations["Rotor1"] //get Rotation of rotor 1
Rotor2 = Rotations["Rotor2"] //get Rotation of rotor 2
Rotor3 = Rotations["Rotor3"] //get Rotation of rotor 3
Key1 = Keys["Rotor1"] //get Layout 1
Key2 = Keys["Rotor2"] //get Layout 2
Key3 = Keys["Rotor3"] //get Layout 3

encryptedText = EnigmaMachine.Encrypt("Example string getting encrypted")
d = EnigmaMachine.Decrypt(encryptedText,rotation1=Rotor1,rotation2=Rotor2,rotation3=Rotor3,code1=Key1,code2=Key2,code3=Key3)

print(f"Encrypted: {encryptedText}")
print(f"Decrypted: {d}")

Output (May vary)

Encrypted: Reotmlc pvdxex mxkwpqp ekxafactt
Decrypted: Example string getting encrypted

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EngimaEncryptionConcept-0.0.5.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file EngimaEncryptionConcept-0.0.5.tar.gz.

File metadata

  • Download URL: EngimaEncryptionConcept-0.0.5.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for EngimaEncryptionConcept-0.0.5.tar.gz
Algorithm Hash digest
SHA256 fddac2d1cf72ee8e4f0e5c36c19dfbcb3dd01c345e0ff375e15172c5da260c30
MD5 aa7f62add19abbb24636b9486f41cf94
BLAKE2b-256 b20096b620ec230fc0478a6505e3b6e872ed850c3b13556c6fcab65978919840

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page