Class: MultiPassword::Strategies::BCrypt
- Inherits:
-
Object
- Object
- MultiPassword::Strategies::BCrypt
- Includes:
- MultiPassword::Strategy
- Defined in:
- lib/multi_password/strategies/bcrypt.rb
Instance Method Summary collapse
- #create(password, options = {}) ⇒ Object
- #validate_options(options) ⇒ Object
- #verify(password, encrypted_password) ⇒ Object
Methods included from MultiPassword::Strategy
Instance Method Details
#create(password, options = {}) ⇒ Object
11 12 13 |
# File 'lib/multi_password/strategies/bcrypt.rb', line 11 def create(password, = {}) ::BCrypt::Password.create(password, ()).to_s end |
#validate_options(options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/multi_password/strategies/bcrypt.rb', line 19 def () return if .empty? cost = [:cost] if !cost.is_a?(Integer) || cost < 4 || cost > 31 raise InvalidOptions.new('bcrypt', 'cost must be an integer between 4 and 31') end end |
#verify(password, encrypted_password) ⇒ Object
15 16 17 |
# File 'lib/multi_password/strategies/bcrypt.rb', line 15 def verify(password, encrypted_password) ::BCrypt::Password.new(encrypted_password) == password end |