Class: MultiPassword::Strategies::Argon2
- Inherits:
-
Object
- Object
- MultiPassword::Strategies::Argon2
- Includes:
- MultiPassword::Strategy
- Defined in:
- lib/multi_password/strategies/argon2.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/argon2.rb', line 11 def create(password, = {}) ::Argon2::Password.new(()).create(password) end |
#validate_options(options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/multi_password/strategies/argon2.rb', line 19 def () return if .empty? t_cost = [:t_cost] m_cost = [:m_cost] if t_cost && (!t_cost.is_a?(Integer) || t_cost < 1 || t_cost > 750) raise InvalidOptions.new('argon2', 't_cost must be an integer between 1 and 750') end if m_cost && (!m_cost.is_a?(Integer) || m_cost < 1 || m_cost > 31) raise InvalidOptions.new('argon2', 'm_cost must be an integer between 1 and 31') end end |
#verify(password, encrypted_password) ⇒ Object
15 16 17 |
# File 'lib/multi_password/strategies/argon2.rb', line 15 def verify(password, encrypted_password) ::Argon2::Password.verify_password(password, encrypted_password) end |