Class: SequelAuth::Providers::Bcrypt
- Inherits:
-
Object
- Object
- SequelAuth::Providers::Bcrypt
- Defined in:
- lib/providers/bcrypt.rb
Class Method Summary collapse
Class Method Details
.cost ⇒ Object
8 9 10 |
# File 'lib/providers/bcrypt.rb', line 8 def cost @cost ||= ::BCrypt::Engine.cost end |
.cost=(val) ⇒ Object
12 13 14 15 |
# File 'lib/providers/bcrypt.rb', line 12 def cost=(val) raise ArgumentError,"cost < #{min_cost} not allowed!" if val < min_cost @cost = val end |
.encrypt(password) ⇒ Object
17 18 19 20 |
# File 'lib/providers/bcrypt.rb', line 17 def encrypt(password) raise ArgumentError, "password not a valid string" if !password.is_a?(String) || password.strip.empty? ::BCrypt::Password.create(password, cost: cost) end |
.matches?(hash, password) ⇒ Boolean
22 23 24 25 26 |
# File 'lib/providers/bcrypt.rb', line 22 def matches?(hash,password) ::BCrypt::Password.new(hash)==password rescue ::BCrypt::Errors::InvalidHash false end |