1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'digest/md5'
$TARGET = "2c4972c770836eaf3b237a561b06daaa"
 
def brute_force(target)
  tries = 0
  ('A'..'AAAAAAAAA').each do |candidate|
    tries+=1
    puts "Testing: " + candidate if tries%10000==0
    hashed = Digest::MD5.hexdigest candidate
    hashed =Digest::MD5.hexdigest hashed
    return candidate if (hashed == target) 
  end
  #f
end
 
puts brute_force($TARGET)