class HTAuth::Crypt

The basic crypt algorithm

Constants

ENTRY_LENGTH
ENTRY_REGEX

Public Class Methods

extract_salt_from_existing_password_field(existing) click to toggle source
# File lib/htauth/crypt.rb, line 14
def self.extract_salt_from_existing_password_field(existing)
  existing[0,2]
end
handles?(password_entry) click to toggle source
# File lib/htauth/crypt.rb, line 10
def self.handles?(password_entry)
  ENTRY_REGEX.match?(password_entry)
end
new(params = {}) click to toggle source
# File lib/htauth/crypt.rb, line 18
def initialize(params = {})
  if existing = (params['existing'] || params[:existing]) then
    @salt = self.class.extract_salt_from_existing_password_field(existing)
  else
    @salt = params[:salt] || params['salt'] || gen_salt
  end
end

Public Instance Methods

encode(password) click to toggle source
# File lib/htauth/crypt.rb, line 26
def encode(password)
  password.crypt(@salt)
end