Skip to content

Instantly share code, notes, and snippets.

@KyCodeHuynh
Last active June 4, 2016 18:25
Show Gist options
  • Save KyCodeHuynh/7841c33f8fbc8bbb3979 to your computer and use it in GitHub Desktop.
Save KyCodeHuynh/7841c33f8fbc8bbb3979 to your computer and use it in GitHub Desktop.
Benchmark how long it takes to hash a password with Bcrypt in Ruby using a particular cost factor

Make sure that the bcrypt gem has been installed.

require 'Benchmark'
require 'bcrypt'
Benchmark.measure { BCrypt::Password.create('secret', :cost => 12) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment