abcdefghijohn / Enigma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enigma

the-imitation-game-movie-wallpaper-16

BackEnd Mod1 Final Project

Table of Contents


History


The Enigma machine is an encryption device developed and used in the early- to mid-20th century but became widely know when it was employed extensively by Nazi Germany during World War II, in all branches of the German military. The Enigma machine was invented by the German engineer Arthur Scherbius at the end of World War I. The device was patented and started being marketed in 1923 as the Enigma machine.

Pre-war German military planning emphasized fast, mobile forces and tactics, later known as blitzkrieg, which depend on radio communication for command and coordination. Since adversaries would likely intercept radio signals, messages would have to be protected with secure encoding. Compact and easily portable, the Enigma machine filled that need.

enigma-machine-working

The machine itself consists of 4 key parts; the keyboard, plugboard, reflector, and rotors. In order to encrypt and decrypt the message both the sender and receiver would need a key and date. The key being a randomly generated 5 digit number and the date being today's date.

The sender would input the message into the keyboard which would then be switched around in the plugboard, which is then sent to the three physical rotors that were wired randomly, in order to add complexity the first rotor would shift one step after each press of the key. The reflector then sends the reflected signal to the lightboard which lights up a corresponding letter based on the key and date. The receiver would then need to use the key and date that the sender used in order to decrypt the message.

Overview


Create an Enigma machine in ruby that can take a message written in a txt file and encrypt to an encrypted.txt file. Then use the key and date in order to decrypt aformentioned file in to a decrypted.txt file.

Encrypting


First write a message that you would like to be encrypted in the message.txt file. Then run the command:

ruby ./lib/encrypt.rb message.txt encrypted.txt

Upon which the encrypted text will be written to the encrypted.txt file and you will be given a confirmation that looks like this:

Created encrypted.txt with the key 03211 and date 210920

In the confirmation message the key and date are given which will be need later for decrypting.

Decrypting


In order to decrypt a message, we would run the command like previously in encrypting with the addition of the previously provided key and date.

ruby ./lib/decrypt.rb encrypted.txt decrypted.txt 03211 210920

Which would then return the decrypted text into the decrypted.txt file and return the message:

Created decrypted.txt with the key 03211 and date 210920

Self Evaluation


Category Score Reason
Functionality 3 Both encrypt and decrypt work from command line. All tests pass.
OOP 3 Methods are in the classes they belong to, module is implemented, and helper methods are used
Ruby Conventions 3 Code is indented and methods are named properly based on function.
TDD 3 Rake passes, all methods including helpers have tests, simple cov shows 100% coverage.
Version Control 3 Have over 30 commits, pull requests were made based on function.

Takeaways

Things I learned:

  • Stubs - I won't say I'm completely comfortable but I was able to use them quite a bit in this project and I feel more confident about them now.
  • Calling files - Last go around one of the parts of the Nightwriter project I had great difficulty with was calling files from the command line. I was able to practice it in Enigma and was very excited when my encrypt and decrypt functions were working.
  • #zip, #rjust, #digits, #strftime, and #rotate were some of the new methods I used during this project.

Things I'd do differently:

  • I would take a crack at cracking the code, I can honestly say that I was so happy that I got everything to work that I felt intimidated by cracking and was worried I would run out of time without finishing it and having other functionality break on me.

About


Languages

Language:HTML 83.3%Language:Ruby 16.7%