Sha256: 65c13a5d2d11f58d8db26d09da4849d06cf18fdee85401bdd7baa66a0df3e0ce

Contents?: true

Size: 985 Bytes

Versions: 55

Compression:

Stored size: 985 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

55 entries across 55 versions & 9 rubygems

Version Path
authlogic-4.0.1 lib/authlogic/crypto_providers/md5.rb
authlogic-4.0.0 lib/authlogic/crypto_providers/md5.rb
authlogic-3.8.0 lib/authlogic/crypto_providers/md5.rb
authlogic-3.7.0 lib/authlogic/crypto_providers/md5.rb
authlogic-3.6.1 lib/authlogic/crypto_providers/md5.rb
authlogic-3.6.0 lib/authlogic/crypto_providers/md5.rb
authlogic-3.5.0 lib/authlogic/crypto_providers/md5.rb
godfat-rubycas-server-0.8.0.20090918 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.6 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.5.pre lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.4.pre lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.4 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.3alpha lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapse-rubycas-server-1.1.3.pre lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapses-cas-0.1.11 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapses-cas-0.1.10 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
synapses-cas-0.1.9 lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
ror-rubycas-server-1.0.c lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
ror-rubycas-server-1.0.b lib/casserver/authenticators/authlogic_crypto_providers/md5.rb
ror-rubycas-server-1.0.a lib/casserver/authenticators/authlogic_crypto_providers/md5.rb