Methods
Class Public methods
new() Link
# File activemodel/lib/active_model/secure_password/argon2_password.rb, line 6 def initialize # Load argon2 gem only when has_secure_password with :argon2 is used. # This is to avoid Active Model (and by extension the entire framework) # being dependent on a binary library. require "argon2" rescue LoadError warn "You don't have argon2 installed in your application. Please add it to your Gemfile and run bundle install." raise end
Instance Public methods
algorithm_name() Link
Returns the algorithm name.
hash_password(unencrypted_password) Link
Hashes the unencrypted password using Argon2.
# File activemodel/lib/active_model/secure_password/argon2_password.rb, line 17 def hash_password(unencrypted_password) if ActiveModel::SecurePassword.min_cost ::Argon2::Password.new(profile: :unsafe_cheapest).create(unencrypted_password) else ::Argon2::Password.create(unencrypted_password) end end
password_salt(digest) Link
Generates the salt from the password digest.
validate(_record, _attribute) Link
Validates the password and adds error to the record in the given attribute. Argon2 has no maximum input size, no validation needed.