Class: CommunityEngineSha1CryptoMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/community_engine/community_engine_sha1_crypto_method.rb

Class Method Summary collapse

Class Method Details

.encrypt(*tokens) ⇒ Object



2
3
4
5
6
7
# File 'lib/community_engine/community_engine_sha1_crypto_method.rb', line 2

def self.encrypt(*tokens)
  tokens = tokens.flatten
  password = tokens.shift
  salt = tokens.shift
  Digest::SHA1.hexdigest(['', salt, password, ''].join('--'))
end

.matches?(crypted, *tokens) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/community_engine/community_engine_sha1_crypto_method.rb', line 9

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