Class: HTAuth::Sha1

Inherits:
Algorithm show all
Defined in:
lib/htauth/sha1.rb

Overview

Internal: an implementation of the SHA based encoding algorithm as used in the apache htpasswd -s option

Constant Summary

Constants inherited from Algorithm

Algorithm::CRYPT, Algorithm::DEFAULT, Algorithm::EXISTING, Algorithm::MD5, Algorithm::PLAINTEXT, Algorithm::SALT_CHARS, Algorithm::SHA1

Instance Method Summary collapse

Methods inherited from Algorithm

algorithm_from_name, algorithms_from_field, #gen_salt, inherited, secure_compare, sub_klasses, #to_64

Constructor Details

#initialize(params = {}) ⇒ Sha1

ignore the params



12
13
# File 'lib/htauth/sha1.rb', line 12

def initialize(params = {}) 
end

Instance Method Details

#encode(password) ⇒ Object



19
20
21
# File 'lib/htauth/sha1.rb', line 19

def encode(password)
  "#{prefix}#{Base64.encode64(::Digest::SHA1.digest(password)).strip}"
end

#prefixObject



15
16
17
# File 'lib/htauth/sha1.rb', line 15

def prefix
  "{SHA}"
end