Skip to content

Commit

Permalink
support cost option for bcrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
duritong committed Jun 7, 2016
1 parent 6c74769 commit 8d38b17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

* Add open method to be able to immediately close a trocla store after using it
* Add typesafe charset
* Support cost option for bcrypt

## to 0.2.3

Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -168,6 +168,11 @@ options to work properly. These are documented here:
Password hashes for PostgreSQL servers. Requires the option `username` to be set
to the username to which the password will be assigned.

### bcrypt

You are able to tune the [cost factor of bcrypt](https://github.com/codahale/bcrypt-ruby#cost-factors) by passing the option `cost`.
Note: ruby bcrypt does not support a [cost > 31](https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/password.rb#L45).

### x509

This format takes a set of additional options. Required are:
Expand Down
3 changes: 2 additions & 1 deletion lib/trocla/formats/bcrypt.rb
@@ -1,6 +1,7 @@
class Trocla::Formats::Bcrypt < Trocla::Formats::Base
expensive true
require 'bcrypt'
def format(plain_password,options={})
BCrypt::Password.create(plain_password).to_s
BCrypt::Password.create(plain_password, :cost => options['cost']||BCrypt::Engine.cost).to_s
end
end

0 comments on commit 8d38b17

Please sign in to comment.