Class: Ratsel::Crack
- Inherits:
-
Object
- Object
- Ratsel::Crack
- Includes:
- SendMessage
- Defined in:
- lib/ratsel/crack.rb
Instance Attribute Summary collapse
-
#cracked_txt ⇒ Object
readonly
Returns the value of attribute cracked_txt.
-
#encrypted_txt ⇒ Object
readonly
Returns the value of attribute encrypted_txt.
-
#encryption_date ⇒ Object
readonly
Returns the value of attribute encryption_date.
-
#encryption_key ⇒ Object
readonly
Returns the value of attribute encryption_key.
Instance Method Summary collapse
- #crack ⇒ Object
-
#initialize(encrypted_txt, cracked_txt, encryption_date) ⇒ Crack
constructor
A new instance of Crack.
Methods included from SendMessage
Constructor Details
#initialize(encrypted_txt, cracked_txt, encryption_date) ⇒ Crack
Returns a new instance of Crack.
6 7 8 9 10 11 |
# File 'lib/ratsel/crack.rb', line 6 def initialize(encrypted_txt, cracked_txt, encryption_date) @encryption_key = nil @encryption_date = encryption_date @encrypted_txt = encrypted_txt @cracked_txt = cracked_txt end |
Instance Attribute Details
#cracked_txt ⇒ Object (readonly)
Returns the value of attribute cracked_txt.
4 5 6 |
# File 'lib/ratsel/crack.rb', line 4 def cracked_txt @cracked_txt end |
#encrypted_txt ⇒ Object (readonly)
Returns the value of attribute encrypted_txt.
4 5 6 |
# File 'lib/ratsel/crack.rb', line 4 def encrypted_txt @encrypted_txt end |
#encryption_date ⇒ Object (readonly)
Returns the value of attribute encryption_date.
4 5 6 |
# File 'lib/ratsel/crack.rb', line 4 def encryption_date @encryption_date end |
#encryption_key ⇒ Object (readonly)
Returns the value of attribute encryption_key.
4 5 6 |
# File 'lib/ratsel/crack.rb', line 4 def encryption_key @encryption_key end |
Instance Method Details
#crack ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ratsel/crack.rb', line 13 def crack last_char = '..end..' = Ratsel::Accessor.read_file_text(encrypted_txt) = .last(4) last_4_char = last_char.split("").last(4) .rotate!(4 - (.size % 4)) last_4_char.rotate!(4 - (.size % 4)) offsets = Ratsel::Helpers.offsets_array(@encryption_date) differences = Ratsel::Helpers.get_differences( , last_4_char, offsets ) # Get the missing key key = Ratsel::Helpers.get_key(differences) # Initialize Decrypt method with the missing key Ratsel::Decrypt.new(encrypted_txt, cracked_txt, key, encryption_date).decrypt end |