Skip to content

Instantly share code, notes, and snippets.

@imwilsonxu
Created September 24, 2012 09:16
Show Gist options
  • Save imwilsonxu/3775084 to your computer and use it in GitHub Desktop.
Save imwilsonxu/3775084 to your computer and use it in GitHub Desktop.
Compare md5 with bcrypt
require 'benchmark'
require 'bcrypt'
password = 'Shh...'
amount = 100
Benchmark.bmbm(20) do |run|
run.report("Bcrypt(10)") do
amount.times do
hash = BCrypt::Password.create(password, :cost => 10)
end
end
run.report("Bcrypt(15)") do
amount.times do
hash = BCrypt::Password.create(password, :cost => 15)
end
end
run.report("MD5") do
amount.times do
hash = Digest::MD5.hexdigest(password)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment