Class: Auth::Encryptors::Sha512

Inherits:
Object
  • Object
show all
Defined in:
lib/auth/encryptors/sha512.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.stretchesObject



6
7
8
# File 'lib/auth/encryptors/sha512.rb', line 6

def stretches
  @stretches ||= 20
end

.token_delimeterObject

Returns the value of attribute token_delimeter.



3
4
5
# File 'lib/auth/encryptors/sha512.rb', line 3

def token_delimeter
  @token_delimeter
end

Class Method Details

.encrypt(*what) ⇒ Object



10
11
12
13
14
# File 'lib/auth/encryptors/sha512.rb', line 10

def encrypt(*what)
  digest = what.flatten.join(token_delimeter)
  stretches.times { digest = Digest::SHA512.hexdigest(digest) }
  digest
end

.matches?(encrypted_copy, *what) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/auth/encryptors/sha512.rb', line 16

def matches?(encrypted_copy, *what)
  encrypt(*what) == encrypted_copy
end