Class: HTAuth::Sha1
Overview
Internal: an implementation of the SHA based encoding algorithm as used in the apache htpasswd -s option
Constant Summary collapse
- PREFIX =
'{SHA}'.freeze
- ENTRY_REGEX =
%r[\A#{Regexp.escape(PREFIX)}[A-Za-z0-9+\/=]{28}\z].freeze
Constants inherited from Algorithm
Algorithm::ARGON2, Algorithm::BCRYPT, Algorithm::CRYPT, Algorithm::DEFAULT, Algorithm::EXISTING, Algorithm::MD5, Algorithm::PLAINTEXT, Algorithm::SALT_CHARS, Algorithm::SALT_LENGTH, Algorithm::SHA1
Class Method Summary collapse
Instance Method Summary collapse
- #encode(password) ⇒ Object
-
#initialize(params = {}) ⇒ Sha1
constructor
ignore the params.
Methods inherited from Algorithm
algorithm_from_field, algorithm_from_name, algorithm_name, #gen_salt, secure_compare, #to_64, #verify_password?
Methods included from DescendantTracker
#children, #find_child, #inherited
Constructor Details
#initialize(params = {}) ⇒ Sha1
ignore the params
19 20 |
# File 'lib/htauth/sha1.rb', line 19 def initialize(params = {}) end |
Class Method Details
.handles?(password_entry) ⇒ Boolean
14 15 16 |
# File 'lib/htauth/sha1.rb', line 14 def self.handles?(password_entry) ENTRY_REGEX.match?(password_entry) end |
Instance Method Details
#encode(password) ⇒ Object
22 23 24 |
# File 'lib/htauth/sha1.rb', line 22 def encode(password) "#{PREFIX}#{Base64.encode64(::Digest::SHA1.digest(password)).strip}" end |