Sha256: 58c82a0ddc5d07545e4ca2179230452f3656fe5da4e49117424a1477d96f5883

Contents?: true

Size: 1011 Bytes

Versions: 82

Compression:

Stored size: 1011 Bytes

Contents

require "digest/md5"
 
module Authlogic
  module CryptoProviders
    # This class was made for the users transitioning from md5 based systems. 
    # I highly discourage using this crypto provider as it superbly inferior 
    # to your other options.
    #
    # Please use any other provider offered by Authlogic.
    class MD5
      class << self
        attr_accessor :join_token
        
        # The number of times to loop through the encryption.
        def stretches
          @stretches ||= 1
        end
        attr_writer :stretches
        
        # Turns your raw password into a MD5 hash.
        def encrypt(*tokens)
          digest = tokens.flatten.join(join_token)
          stretches.times { digest = Digest::MD5.hexdigest(digest) }
          digest
        end
        
        # Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
        def matches?(crypted, *tokens)
          encrypt(*tokens) == crypted
        end
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 25 rubygems

Version Path
jdl-authlogic-2.1.6.1 lib/authlogic/crypto_providers/md5.rb
authlogic-2.1.6 lib/authlogic/crypto_providers/md5.rb
lockbox_middleware-1.2.1 vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/md5.rb
Empact-authlogic-2.1.5 lib/authlogic/crypto_providers/md5.rb
authlogic-2.1.5 lib/authlogic/crypto_providers/md5.rb
authlogic-2.1.4 lib/authlogic/crypto_providers/md5.rb
Empact-authlogic-2.1.4 lib/authlogic/crypto_providers/md5.rb
namxam-authlogic-2.1.3.1 lib/authlogic/crypto_providers/md5.rb
drogus-authlogic-2.1.3 lib/authlogic/crypto_providers/md5.rb
novelys_authlogic-2.1.6 lib/novelys_authlogic/crypto_providers/md5.rb
novelys_authlogic-2.1.5 lib/novelys_authlogic/crypto_providers/md5.rb
novelys_authlogic-2.1.4 lib/novelys_authlogic/crypto_providers/md5.rb
novelys_authlogic-2.1.3 lib/authlogic/crypto_providers/md5.rb
brontes3d-rubycas-server-0.8.0.20100111 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
ginst-2009.12.8 vendor/plugins/authlogic/lib/authlogic/crypto_providers/md5.rb
brontes3d-rubycas-server-0.8.0.20091208 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
brontes3d-rubycas-server-0.8.0.20090812 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
skippy-authlogic-2.1.3 lib/authlogic/crypto_providers/md5.rb
ginst-2009.11.24 vendor/plugins/authlogic/lib/authlogic/crypto_providers/md5.rb
ginst-2009.11.23 vendor/plugins/authlogic/lib/authlogic/crypto_providers/md5.rb