Sha256: 5a8554ed085b479bbdbb38fc46e92b28d6a2b5a5a2f37df8c094840b5bc4aeba

Contents?: true

Size: 812 Bytes

Versions: 23

Compression:

Stored size: 812 Bytes

Contents

require "digest/sha1"

module Devise
  module Encryptors
    # = RestfulAuthenticationSha1
    # Simulates Restful Authentication's default encryption mechanism.
    # Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
    # Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES. Should be set to 10 in
    # the initializer to simulate the default behavior.
    class RestfulAuthenticationSha1 < Base

      # Generates a default password digest based on salt, pepper and the
      # incoming password.
      def self.digest(password, stretches, salt, pepper)
        digest = pepper
        stretches.times { digest = Digest::SHA1.hexdigest([digest, salt, password, pepper].flatten.join('--')) }
        digest
      end

    end
  end
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
devise-2.0.6 lib/devise/encryptors/restful_authentication_sha1.rb
devise_sociable-0.1.0 vendor/bundle/gems/devise-1.5.4/lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.5 lib/devise/encryptors/restful_authentication_sha1.rb
devise-1.5.4 lib/devise/encryptors/restful_authentication_sha1.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/lib/devise/encryptors/restful_authentication_sha1.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/lib/devise/encryptors/restful_authentication_sha1.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/lib/devise/encryptors/restful_authentication_sha1.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/lib/devise/encryptors/restful_authentication_sha1.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/lib/devise/encryptors/restful_authentication_sha1.rb
upstream-devise-2.1.0.rc lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.1.0.rc lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.4 lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.2 lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.1 lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.0 lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.0.rc2 lib/devise/encryptors/restful_authentication_sha1.rb
devise-2.0.0.rc lib/devise/encryptors/restful_authentication_sha1.rb
devise-1.5.3 lib/devise/encryptors/restful_authentication_sha1.rb
cloudfoundry-devise-1.5.2 lib/devise/encryptors/restful_authentication_sha1.rb
devise-1.5.2 lib/devise/encryptors/restful_authentication_sha1.rb