class Authlogic::CryptoProviders::Sha1::V2

A poor choice. There are known attacks against this algorithm.

Attributes

join_token[W]
stretches[W]

Public Class Methods

encrypt(*tokens) click to toggle source

Turns your raw password into a Sha1 hash.

# File lib/authlogic/crypto_providers/sha1/v2.rb, line 23
def encrypt(*tokens)
  tokens = tokens.flatten
  digest = tokens.shift
  stretches.times do
    digest = Digest::SHA1.digest([digest, *tokens].join(join_token))
  end
  digest.unpack1("H*")
end
join_token() click to toggle source
# File lib/authlogic/crypto_providers/sha1/v2.rb, line 11
def join_token
  @join_token ||= "--"
end
matches?(crypted, *tokens) click to toggle source

Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.

# File lib/authlogic/crypto_providers/sha1/v2.rb, line 34
def matches?(crypted, *tokens)
  encrypt(*tokens) == crypted
end
stretches() click to toggle source

The number of times to loop through the encryption.

# File lib/authlogic/crypto_providers/sha1/v2.rb, line 17
def stretches
  @stretches ||= 10
end