Created
July 16, 2013 20:30
-
-
Save tmornini/6012381 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler' | |
Bundler.require :default | |
require 'benchmark' | |
secret = 'APLkbvwfFosYHj3m4dvnE5' | |
hashes = [] | |
n = 1000 | |
Benchmark.bm do |x| | |
x.report 'bcrypt-create' do | |
n.times do | |
hashes << BCrypt::Password.create( secret, | |
:cost => 5 ) | |
end | |
end | |
x.report 'bcrypt-verify' do | |
n.times do | |
raise StandardError unless BCrypt::Password.new( hashes.pop ) == secret | |
end | |
end | |
end |
This file contains 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
source 'https://rubygems.org' | |
gem 'bcrypt-ruby', :require => 'bcrypt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment