Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'digest/sha1'
- def combinator(arr, comb_arr = arr, len)
- return if len == 0
- if len == 1
- return comb_arr
- else
- tmp_arr = []
- arr.each do |ch|
- comb_arr.each do |comb|
- tmp_arr << comb + ch
- end
- end
- combinator(arr, tmp_arr, len - 1)
- end
- end
- def pwd_brute_force(md5_str, len)
- alphabet = ('a'..'z').to_a
- pwd_combos = combinator(alphabet, len)
- pwd_combos.each do |pwd|
- return pwd if Digest::SHA1.hexdigest(pwd) == md5_str
- end
- 'Not found'
- end
- md5_str = Digest::SHA1.hexdigest("hey")
- puts pwd_brute_force(md5_str, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement