Class: Authentication::Logic::CryptoProviders::Sha1
- Inherits:
-
Object
- Object
- Authentication::Logic::CryptoProviders::Sha1
- Defined in:
- lib/auth/logic/crypto_providers/sha1.rb,
lib/auth/logic/crypto_providers/sha1/v2.rb
Overview
A poor choice. There are known attacks against this algorithm.
Defined Under Namespace
Classes: V2
Class Attribute Summary collapse
- .join_token ⇒ Object
-
.stretches ⇒ Object
The number of times to loop through the encryption.
Class Method Summary collapse
-
.encrypt(*tokens) ⇒ Object
Turns your raw password into a Sha1 hash.
-
.matches?(crypted, *tokens) ⇒ Boolean
Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
Class Attribute Details
.join_token ⇒ Object
14 15 16 |
# File 'lib/auth/logic/crypto_providers/sha1.rb', line 14 def join_token @join_token ||= "--" end |
.stretches ⇒ Object
The number of times to loop through the encryption.
20 21 22 |
# File 'lib/auth/logic/crypto_providers/sha1.rb', line 20 def stretches @stretches ||= 10 end |
Class Method Details
.encrypt(*tokens) ⇒ Object
Turns your raw password into a Sha1 hash.
25 26 27 28 29 30 31 32 |
# File 'lib/auth/logic/crypto_providers/sha1.rb', line 25 def encrypt(*tokens) tokens = tokens.flatten digest = tokens.shift stretches.times do digest = Digest::SHA1.hexdigest([digest, *tokens].join(join_token)) end digest end |
.matches?(crypted, *tokens) ⇒ Boolean
Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
36 37 38 |
# File 'lib/auth/logic/crypto_providers/sha1.rb', line 36 def matches?(crypted, *tokens) encrypt(*tokens) == crypted end |