Class: EnigmaEncrypto::RotationNumGen

Inherits:
Object
  • Object
show all
Defined in:
lib/enigma_encrypto/rotation_num_gen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRotationNumGen

Returns a new instance of RotationNumGen.



10
11
12
13
14
15
16
17
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 10

def initialize
  @key_without_offset = KeyGen.new
  @key = @key_without_offset.initial_rotation_keys
  @showkey = @key_without_offset.display_key
  @offsetgen = DateOffsetGen.new
  @offset = @offsetgen.get_offset
  @today_date = @offsetgen.todays_date
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



8
9
10
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 8

def key
  @key
end

#offsetObject

Returns the value of attribute offset.



8
9
10
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 8

def offset
  @offset
end

#showkeyObject

Returns the value of attribute showkey.



8
9
10
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 8

def showkey
  @showkey
end

#today_dateObject

Returns the value of attribute today_date.



8
9
10
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 8

def today_date
  @today_date
end

Instance Method Details

#crack_num_arr(key, date) ⇒ Object



33
34
35
36
37
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 33

def crack_num_arr(key, date)
  @key = key
  @offset = date
  rotation_num_array
end

#reverse_num_array(key, date) ⇒ Object



27
28
29
30
31
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 27

def reverse_num_array(key, date)
  @offset = @offsetgen.get_decrypter_offset(date)
  @key = @key_without_offset.initial_decryption_keys(key)
  rotation_num_array
end

#rotation_num_arrayObject



19
20
21
22
23
24
25
# File 'lib/enigma_encrypto/rotation_num_gen.rb', line 19

def rotation_num_array
  rotation_num = []
  4.times do |index|
    rotation_num << @key[index] + @offset[index]
  end
  rotation_num
end