Module: EnigmaRuby

Defined in:
lib/enigma_ruby.rb,
lib/enigma_ruby/rotor.rb,
lib/enigma_ruby/enigma.rb,
lib/enigma_ruby/version.rb,
lib/enigma_ruby/plugboard.rb,
lib/enigma_ruby/reflector.rb,
lib/enigma_ruby/commands/command.rb,
lib/enigma_ruby/commands/reflect_command.rb,
lib/enigma_ruby/commands/advance_rotors_command.rb,
lib/enigma_ruby/commands/swap_plugboard_command.rb,
lib/enigma_ruby/commands/encode_rotor_forward_command.rb,
lib/enigma_ruby/commands/encode_rotor_backward_command.rb

Defined Under Namespace

Classes: AdvanceRotorsCommand, Command, EncodeRotorBackwardCommand, EncodeRotorForwardCommand, Enigma, Plugboard, ReflectCommand, Reflector, Rotor, SwapPlugboardCommand

Constant Summary collapse

DEFAULT_ROTOR_SETTINGS =
[
  { wiring: 'EKMFLGDQVZNTOWYHXUSPAIBRCJ', position: 12 },
  { wiring: 'AJDKSIRUXBLHWTMCQGZNPYFVOE', position: 2 },
  { wiring: 'BDFHJLCPRTXVZNYEIWGAKMUSQO', position: 10 },
].freeze
SKIP_CHARACTERS_REGEX =
/[']/.freeze
NON_ENCRYPTED_CHARACTERS_REGEX =
/[ .,;0-9]/.freeze
VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.encrypt(cleartext, rotor_settings = DEFAULT_ROTOR_SETTINGS) ⇒ Object



20
21
22
# File 'lib/enigma_ruby.rb', line 20

def self.encrypt(cleartext, rotor_settings = DEFAULT_ROTOR_SETTINGS)
  Enigma.new(rotor_settings).encrypt(cleartext)
end