Class: CryptoToolchain::Tools::MT19937SeedRecoverer

Inherits:
Object
  • Object
show all
Defined in:
lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(extracted, start: default_start, finish: Time.now.to_i) ⇒ MT19937SeedRecoverer

Returns a new instance of MT19937SeedRecoverer.



4
5
6
7
8
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 4

def initialize(extracted, start: default_start, finish: Time.now.to_i)
  @extracted = extracted
  @start = start
  @finish = finish
end

Instance Attribute Details

#extractedObject (readonly)

Returns the value of attribute extracted.



19
20
21
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 19

def extracted
  @extracted
end

#finishObject (readonly)

Returns the value of attribute finish.



19
20
21
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 19

def finish
  @finish
end

#startObject (readonly)

Returns the value of attribute start.



19
20
21
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 19

def start
  @start
end

Instance Method Details

#default_startObject

One hour ago



22
23
24
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 22

def default_start
  Time.now.to_i - (3600)
end

#executeObject

Raises:

  • (RuntimeError)


10
11
12
13
14
15
16
17
# File 'lib/crypto_toolchain/tools/mt_19937_seed_recoverer.rb', line 10

def execute
  (start..finish).each do |seed|
    if CryptoToolchain::Utilities::MT19937.new(seed).extract == extracted
      return seed
    end
  end
  raise RuntimeError, "Did not find the seed; consider expanding start and finish"
end