Trying to learn Elixir by modeling an Enigma machine, inspired by the Ruby code written by Albert Still in Understanding the Enigma machine with 30 lines of Ruby.
Mine is a lot more than 30 lines, but it's heavily commented and Elxir seems to have less magic ways of handling lists and maps than Ruby does with arrays and hashes.
If you're an Elixir pro, feel free to suggest improvements!
Encrypt/decrypt a message with:
Enigma.process_string("SECRETMESSAGE")
To decrypt an encrypted message, supply the encrypted message and the matching plugboard, rotor, and reflector configurations:
Enigma.process_string("LDINKZRVIDGPO", 'YXSDPFLHVQKGOUMEJRCTNIZBAW',
'FKDRHSXGVYNBLZIWMEJQOACUTP', 'XTQFWNBCKYVSZODMJIHPGERAUL',
'MZEVUBYCLKHOSIWQNADGFTRPXJ', 'OQFGUCDPZKJVXWAHBTYRELNMSI')
-
Create some analogs of the real rotors used and try to decrypt some known messages.
-
Play around with the variants like the four-rotor Enigma.
@boonedocks on Twitter