Created
May 15, 2015 18:21
-
-
Save yorickpeterse/edbad48ce3d152afe234 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'thread' | |
puts "rubysl-openssl: #{RubySL::OpenSSL::VERSION}" | |
puts "rubysl-digest: #{RubySL::Digest::VERSION}" | |
Thread.abort_on_exception = true | |
input = 'the cake is possibly a lie' | |
digest = Digest::SHA256.new | |
digest.update(input) | |
expected = digest.hexdigest | |
output = Queue.new | |
puts 'Starting threads...' | |
threads = 10.times.map do | |
Thread.new do | |
loop do | |
digest = Digest::SHA256.new | |
digest.update(input) | |
got = digest.hexdigest | |
output << got unless got == expected | |
end | |
end | |
end | |
got = output.pop | |
threads.each(&:kill) | |
raise "Expected digest #{got.inspect} to equal #{expected.inspect}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment