space hash
This commit is contained in:
parent
b7a063ddb4
commit
121ed94fe6
1 changed files with 31 additions and 0 deletions
31
space-hash.rb
Normal file
31
space-hash.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
require 'digest'
|
||||||
|
|
||||||
|
def prompt(*args)
|
||||||
|
print(*args)
|
||||||
|
gets.chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
WHITESPACE = " \t\u200b\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000"
|
||||||
|
|
||||||
|
def doit(message, regex, limit = 10)
|
||||||
|
return unless limit > 0
|
||||||
|
|
||||||
|
digest = Digest::SHA256.hexdigest message
|
||||||
|
if regex.match? digest
|
||||||
|
p message
|
||||||
|
puts digest
|
||||||
|
exit 0
|
||||||
|
end
|
||||||
|
|
||||||
|
WHITESPACE.each_char do |ws|
|
||||||
|
doit(message + ws, regex, limit - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
message = prompt "Message: "
|
||||||
|
hash_regex = Regexp.new(prompt "Digest regex: ")
|
||||||
|
|
||||||
|
doit(message, hash_regex)
|
||||||
|
|
||||||
|
puts "i give up :("
|
||||||
|
exit 1
|
Loading…
Reference in a new issue