Skip to content

Instantly share code, notes, and snippets.

@nnkken
Created February 10, 2018 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nnkken/0cf3e1472f417f262464d11fa46a242e to your computer and use it in GitHub Desktop.
Save nnkken/0cf3e1472f417f262464d11fa46a242e to your computer and use it in GitHub Desktop.
require "openssl"
def enumerate(n, set, target)
set.repeated_permutation(n) do |arr|
if OpenSSL::Digest.digest("sha1", OpenSSL::Digest.digest("sha1", arr.join)) == target
return arr
end
end
return nil
end
target = [207, 145, 125, 199, 75, 210, 227, 4, 202, 157, 34, 133, 79, 100, 133, 38, 187, 182, 131, 134].pack("c*")
set = ("a".."z").map(&:to_s)
p enumerate(5, set, target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment