Skip to content

Instantly share code, notes, and snippets.

@vonconrad
Created June 25, 2011 13:37
Show Gist options
  • Save vonconrad/1046495 to your computer and use it in GitHub Desktop.
Save vonconrad/1046495 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bcrypt'
require 'digest'
require 'benchmark'
require 'forgery'
password = Forgery(:basic).password(:at_least => 8, :at_most => 20)
Benchmark.bm do |x|
x.report('md5 ') do
1000000.times { Digest::MD5.hexdigest(password) }
end
x.report('sha1 ') do
1000000.times { Digest::SHA1.hexdigest(password) }
end
x.report('bcrypt') do
1000.times { BCrypt::Password.create(password) }
end
end
user system total real
md5 2.490000 0.050000 2.540000 ( 2.574742)
sha1 2.590000 0.050000 2.640000 ( 2.772350)
bcrypt 90.420000 0.290000 90.710000 ( 93.921260)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment