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}"- ENTRY_REGEX =
%r[\A#{Regexp.escape(PREFIX)}[A-Za-z0-9+/=]{28}\z]
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, #to64, #verify_password?
Methods included from DescendantTracker
#children, #find_child, #inherited
Constructor Details
#initialize(_params = {}) ⇒ Sha1
ignore the params
20 21 22 |
# File 'lib/htauth/sha1.rb', line 20 def initialize(_params = {}) super() end |
Class Method Details
.handles?(password_entry) ⇒ Boolean
15 16 17 |
# File 'lib/htauth/sha1.rb', line 15 def self.handles?(password_entry) ENTRY_REGEX.match?(password_entry) end |
Instance Method Details
#encode(password) ⇒ Object
24 25 26 |
# File 'lib/htauth/sha1.rb', line 24 def encode(password) "#{PREFIX}#{Base64.encode64(::Digest::SHA1.digest(password)).strip}" end |