Skip to content

Instantly share code, notes, and snippets.

@SharaaEsper
Last active December 14, 2016 17:06
Show Gist options
  • Save SharaaEsper/b40c427695f6f1d8b32b8d27553140fb to your computer and use it in GitHub Desktop.
Save SharaaEsper/b40c427695f6f1d8b32b8d27553140fb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'digest'
seed='qzyelonm'
index=-1
counter=0
def check_for_key(seed, index)
if Digest::MD5.hexdigest(seed + index.to_s).match(/(.)\1{2,}/).nil?
return false
else
matchset = Digest::MD5.hexdigest(seed + index.to_s).match(/(.)\1{2,}/)[0].chr
(index + 1).upto(index + 1000) do |idx|
if not Digest::MD5.hexdigest(seed + idx.to_s).match(/(#{matchset})\1{4,}/).nil?
return true
end
end
return false
end
end
until counter == 64 do
index +=1
if check_for_key(seed, index) == true
counter += 1
end
end
puts index
#!/usr/bin/env ruby
require 'rubygems'
require 'digest'
seed='qzyelonm'
index=-1
counter=0
def check_for_key(hashes, index)
if hashes[index].match(/(.)\1{2,}/).nil?
return false
else
matchset = hashes[index].match(/(.)\1{2,}/)[0].chr
(index + 1).upto(index + 1000) do |idx|
if not hashes[idx].match(/(#{matchset})\1{4,}/).nil?
return true
end
end
return false
end
end
def rehash(hash)
1.upto(2016) do |foo|
hash = Digest::MD5.hexdigest(hash)
end
return hash
end
puts "Generating hashes...."
hashes = Array.new
0.upto(50000) do |iter|
hashes << rehash(Digest::MD5.hexdigest(seed + iter.to_s))
end
puts "Checking for keys..."
until counter == 64 do
index +=1
if check_for_key(hashes, index) == true
counter += 1
end
end
puts "Answer: #{index}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment