Class: Authlogic::CryptoProviders::Sha1
- Inherits:
-
Object
- Object
- Authlogic::CryptoProviders::Sha1
- Defined in:
- lib/authlogic/crypto_providers/sha1.rb
Overview
This class was made for the users transitioning from restful_authentication. I highly discourage using this crypto provider as it inferior to your other options. Please use any other provider offered by Authlogic.
Class Attribute Summary (collapse)
- + (Object) join_token
-
+ (Object) stretches
The number of times to loop through the encryption.
Class Method Summary (collapse)
-
+ (Object) encrypt(*tokens)
Turns your raw password into a Sha1 hash.
-
+ (Boolean) matches?(crypted, *tokens)
Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
Class Attribute Details
+ (Object) join_token
9 10 11 |
# File 'lib/authlogic/crypto_providers/sha1.rb', line 9 def join_token @join_token ||= "--" end |
+ (Object) stretches
The number of times to loop through the encryption. This is ten because that is what restful_authentication defaults to.
15 16 17 |
# File 'lib/authlogic/crypto_providers/sha1.rb', line 15 def stretches @stretches ||= 10 end |
Class Method Details
+ (Object) encrypt(*tokens)
Turns your raw password into a Sha1 hash.
21 22 23 24 25 26 |
# File 'lib/authlogic/crypto_providers/sha1.rb', line 21 def encrypt(*tokens) tokens = tokens.flatten digest = tokens.shift stretches.times { digest = Digest::SHA1.hexdigest([digest, *tokens].join(join_token)) } digest end |
+ (Boolean) matches?(crypted, *tokens)
Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
29 30 31 |
# File 'lib/authlogic/crypto_providers/sha1.rb', line 29 def matches?(crypted, *tokens) encrypt(*tokens) == crypted end |