Skip to content

Instantly share code, notes, and snippets.

@JoelLindow
Last active March 24, 2017 14:43
Show Gist options
  • Save JoelLindow/728a3c9a6c370fd64d833686cfb33e08 to your computer and use it in GitHub Desktop.
Save JoelLindow/728a3c9a6c370fd64d833686cfb33e08 to your computer and use it in GitHub Desktop.
Enigma Project Psuedocode

Enigma Psuedocode

Paired Project: Joel Lindow / Ben Ross

Program must

  1. Encrypt Messages
  2. Decrypt Messages
  3. Crack Messages (potentially by cycling through all possible date options weighed against Encryption key)

Rules to maintain throughout.

  • a "." always equals "."
  • a " " always equalt " "

1) ENCRYPTION ELEMENT OF PROGRAM

  • First we must create the ability to write a new code to be encrypted.

  • We will want to use the standard 26 letter alphabet as our encryption language (legend).

  • Each letter of the text we desire to encrypt must start at the letter of origin in the original text and advance through the alphabet 1 letter (a comes after z) for each # of rotations calculated.

  • There must be an Encryption Key of 41521 (potentially interchangeable as well) which is divided out as the 4 elements of the "Encryption Rotation". This will divide out into 4 rotating values of 41 15 52 and 21.

  • There will also be a Date Key of the current date. The date provided will be input as: DDMMYY. This will provide us with a 6 digit number. This 6 digit number must be squared. So, March 23rd 2017 would turn into 230317. This squared would be 53045920489. The last 4 digits (0489) of this squared number will be our method of offsetting the original encryption key. This means that the actual completed cypher will be completely different every day, and can only be decrypted if the user knows the date the code was created on or the date key that the last 4 numbers of the date squared equalled to provide the offset numbers.

Example using March 23 2017 (230317) as the date:

ENC KEY   DATE      ROTATION NUM
 A-41   +  A-0   =   A-41
 B-15   +  B-4   =   B-19
 C-52   +  C-8   =   C-60
 D-21   +  D-9   =   D-30

Example of Encryption output:

B E N   R O S S   <-- Original Message
Q X V   V D A W   <-- Encrypted Message
  • Return encrypted message back to the user.

2) DECRYPTION ELEMENT OF PROGRAM

  • We must create the ability to decrypt code

  • User should be able to pass in the date that the message was created on (but any 6 digit date must be allowed, as to allow failed decryption attempts).

    • program will produce the proper decryption/encryption offset when passed the proper key (according to rules from encryption process).
  • User should be able to pass in the key that the message was created with (but any 5 digit key must be allowed, as to allow for failed decryption attempts).

    • program will produce the proper decryption/encryption key-rotations(legend-rotations) when passed the proper key (according to rules from encryption process).
  • Decryption will start decoding on a 1 letter basis. It will start with the letter provided in the encrypted message and then work backward through the encryption-legend according to the same rules as the encryption method (according to the key rotations and the date offsets).

  • Program should return the decrypted message.

3) CRACKING ELEMENT OF PROGRAM

  • User should be able to select the "crack" option

  • Crack function should ask the user if they want to take 1 of 2 options:

    1. Allow cracker to search for familiar words, that might identify a cracked message (or possibly patterns in the alphabet that match these basic words and the words in the encoded message):
      • "and"
      • "in"
      • "the"
      • "I"
    2. Check decoded messages manually
      • Output 1 message at a time whether decoded or decoded improperly until user stops the program (basically a random chance of seeing a decoded option (which would get nearly impossible if you aren't at least providing the program the actuall "key". If you have the key, you would have 365 potential options to let the computer fade through, as it would be trying to crack according to each date on the calendar.)) This may be a poor option, becasue it doesn't truly represent "raw cracking" like you would if you had just the encoded message and no actual idea how it was being encoded. This option may be optional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment