Skip to content

Instantly share code, notes, and snippets.

@burke
Created May 7, 2009 05:06
Show Gist options
  • Save burke/107927 to your computer and use it in GitHub Desktop.
Save burke/107927 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'digest/md5'
def find_match(a, b)
largest = 0
current = 0
(32-largest).times do |aix|
(32-largest).times do |bix|
offset = 0
current = 0
while a[aix+offset] == b[bix+offset]
offset += 1
current +=1
break if (aix+offset)>31 or (bix+offset)>31
end
if current > largest
largest = current
end
end
end
return largest
end
x = "42"
i = 0
largest = 0
loop do
i += 1
old = x
x = Digest::MD5.hexdigest(x)
curr = find_match(old,x)
if curr > largest
puts "#{old} => #{x} : #{curr} (#{i} scanned)"
largest = curr
end
end
#!/usr/bin/env ruby
require 'digest/md5'
x = "42"
save = "0"
i = 0
j = 0
loop do
i += 1
j += 1
x = Digest::MD5.hexdigest(x)
if x == save
puts "Cycle found at #{x}"
exit
end
if j == 100000
save = x
print "."
$stdout.flush
j = 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment