Class: GentleBrute::BruteForcer

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

Instance Method Summary collapse

Constructor Details

#initialize(start_length = 1, cpa_threshold = 24) ⇒ BruteForcer

Returns a new instance of BruteForcer.

Parameters:

  • start_length (Number) (defaults to: 1)

    the starthing length of the string to start generating potential words

  • cpa_threshold (Number) (defaults to: 24)

    the minimum character position analysis score neighboring characters must have



16
17
18
19
# File 'lib/gentle_brute.rb', line 16

def initialize(start_length=1, cpa_threshold=24)
  @odometer = Odometer.new start_length
  @word_analyzer = WordAnalyzer.new cpa_threshold
end

Instance Method Details

#next_valid_phraseString

Returns the next English-like brute force phrase.

Returns:

  • (String)

    the next English-like brute force phrase



22
23
24
25
26
27
28
# File 'lib/gentle_brute.rb', line 22

def next_valid_phrase
  while true
    @odometer.increment
    phrase = @odometer.string_for_odometer
    return phrase if @word_analyzer.is_valid_word? phrase
  end
end