Sha256: f6c90d6717113b1e6e2a1fd80e5b6979fc156a42e48b8b9d27875fb63dccb13b

Contents?: true

Size: 1.17 KB

Versions: 54

Compression:

Stored size: 1.17 KB

Contents

require 'digest/md5'
module Authlogic
  module CryptoProviders
    class Wordpress
      class << self
        ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

        def matches?(crypted, *tokens)
          stretches = 1 << ITOA64.index(crypted[3,1])
          plain, salt = *tokens 
          hashed = Digest::MD5.digest(salt+plain)
          stretches.times do |i|
            hashed = Digest::MD5.digest(hashed+plain)
          end
          crypted[0,12]+encode_64(hashed, 16) == crypted
        end

        def encode_64(input, length)
          output = "" 
          i = 0
          while i < length
            value = input[i] 
            i+=1
            break if value.nil?
            output += ITOA64[value & 0x3f, 1]
            value |= input[i] << 8 if i < length
            output += ITOA64[(value >> 6) & 0x3f, 1]

            i+=1
            break if i >= length
            value |= input[i] << 16 if i < length
            output += ITOA64[(value >> 12) & 0x3f,1]

            i+=1
            break if i >= length
            output += ITOA64[(value >> 18) & 0x3f,1]
          end
          output
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 18 rubygems

Version Path
expertiza-authlogic-2.1.6.1 lib/authlogic/crypto_providers/wordpress.rb
antlypls-authlogic-3.0.3 lib/authlogic/crypto_providers/wordpress.rb
authlogic-3.0.3 lib/authlogic/crypto_providers/wordpress.rb
authlogic-3.0.2 lib/authlogic/crypto_providers/wordpress.rb
authlogic-3.0.1 lib/authlogic/crypto_providers/wordpress.rb
authlogic-3.0.0 lib/authlogic/crypto_providers/wordpress.rb
authlogic-rails3-2.2 lib/authlogic/crypto_providers/wordpress.rb
kb-authlogic-2.1.7 lib/authlogic/crypto_providers/wordpress.rb
wulffeld_authlogic-2.1.3 lib/authlogic/crypto_providers/wordpress.rb
railsware-authlogic-2.1.6.1 lib/authlogic/crypto_providers/wordpress.rb
cotweet-authlogic-2.1.6 lib/authlogic/crypto_providers/wordpress.rb
jdl-authlogic-2.1.6.2 lib/authlogic/crypto_providers/wordpress.rb
jdl-authlogic-2.1.6.1 lib/authlogic/crypto_providers/wordpress.rb
authlogic-2.1.6 lib/authlogic/crypto_providers/wordpress.rb
lockbox_middleware-1.2.1 vendor/gems/authlogic-2.1.3/lib/authlogic/crypto_providers/wordpress.rb
Empact-authlogic-2.1.5 lib/authlogic/crypto_providers/wordpress.rb
authlogic-2.1.5 lib/authlogic/crypto_providers/wordpress.rb
authlogic-2.1.4 lib/authlogic/crypto_providers/wordpress.rb
Empact-authlogic-2.1.4 lib/authlogic/crypto_providers/wordpress.rb
namxam-authlogic-2.1.3.1 lib/authlogic/crypto_providers/wordpress.rb