Class: Authlogic::CryptoProviders::InvisionPowerBoard

Inherits:
Object
  • Object
show all
Defined in:
lib/authlogic/crypto_providers/invision_power_board.rb

Class Method Summary collapse

Class Method Details

.encrypt(*tokens) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/authlogic/crypto_providers/invision_power_board.rb', line 7

def encrypt(*tokens)
  tokens = tokens.flatten
  digest = tokens.shift
  digest = filter_input(digest)

  # Invision's hash: MD5(MD5(salt) + MD5(raw))
  digest = Digest::MD5.hexdigest(Digest::MD5.hexdigest(tokens.join('')) + Digest::MD5.hexdigest(digest))

  digest
end

.matches?(crypted, *tokens) ⇒ Boolean

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/authlogic/crypto_providers/invision_power_board.rb', line 19

def matches?(crypted, *tokens)
  encrypt(*tokens) == crypted
end