Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Brute force MD5 cracker - Ruby Code Bank


Brute force MD5 cracker
Real brute force cracker (check only small letters).
                require 'digest/md5'
def crack(hash, max_length)
  for i in 1..max_length
    for word in ('a'*i..'z'*i)
      if Digest::MD5.new(word) == hash
        return word
      end
    end
  end
end
puts crack(ARGV[0], 5)

            
Comments
ellipsis's avatar
ellipsis 11 years ago

This won't work for passwords with numbers, uppercase, or symbols, but still pretty neat. I like how you give the password length param. It's not bad for an eleven line code.