Class: Authlogic::CryptoProviders::MD5
- Inherits:
-
Object
- Object
- Authlogic::CryptoProviders::MD5
- Defined in:
- lib/authlogic/crypto_providers/md5.rb
Overview
A poor choice. There are known attacks against this algorithm.
Class Attribute Summary collapse
-
.join_token ⇒ Object
Returns the value of attribute join_token.
-
.stretches ⇒ Object
The number of times to loop through the encryption.
Class Method Summary collapse
-
.encrypt(*tokens) ⇒ Object
Turns your raw password into a MD5 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
Returns the value of attribute join_token.
10 11 12 |
# File 'lib/authlogic/crypto_providers/md5.rb', line 10 def join_token @join_token end |
.stretches ⇒ Object
The number of times to loop through the encryption.
13 14 15 |
# File 'lib/authlogic/crypto_providers/md5.rb', line 13 def stretches @stretches ||= 1 end |
Class Method Details
.encrypt(*tokens) ⇒ Object
Turns your raw password into a MD5 hash.
19 20 21 22 23 |
# File 'lib/authlogic/crypto_providers/md5.rb', line 19 def encrypt(*tokens) digest = tokens.flatten.join(join_token) stretches.times { digest = Digest::MD5.hexdigest(digest) } digest end |
.matches?(crypted, *tokens) ⇒ Boolean
Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
27 28 29 |
# File 'lib/authlogic/crypto_providers/md5.rb', line 27 def matches?(crypted, *tokens) encrypt(*tokens) == crypted end |