Module: ClearanceCrypto::SHA512::InstanceMethods

Defined in:
lib/clearance_crypto/sha512.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stretchesObject

The number of times to loop through the encryption.



11
12
13
# File 'lib/clearance_crypto/sha512.rb', line 11

def stretches
  @stretches ||= 20
end

Instance Method Details

#authenticated?(string) ⇒ Boolean



23
24
25
# File 'lib/clearance_crypto/sha512.rb', line 23

def authenticated?(string)
  encrypt(string) == encrypted_password
end

#encrypt(string) ⇒ Object

Turns your raw password into a Sha512 hash.



17
18
19
20
21
# File 'lib/clearance_crypto/sha512.rb', line 17

def encrypt(string)
  digest = "--#{salt}--#{string}--"
  stretches.times { digest = Digest::SHA512.hexdigest(digest) }
  digest
end