Skip to content

Instantly share code, notes, and snippets.

@tmornini
Created July 16, 2013 20:30
Show Gist options
  • Save tmornini/6012381 to your computer and use it in GitHub Desktop.
Save tmornini/6012381 to your computer and use it in GitHub Desktop.
#!/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
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