Sha256: e717d7a7faba876fcc51cde4bf424ad6d542ca457254547fd7e69cbcd5a8edf1

Contents?: true

Size: 726 Bytes

Versions: 35

Compression:

Stored size: 726 Bytes

Contents

require "digest/sha1"

module Devise
  module Encryptors
    # = Sha1
    # Uses the Sha1 hash algorithm to encrypt passwords.
    class Sha1 < Base
      # Gererates a default password digest based on stretches, salt, pepper and the
      # incoming password.
      def self.digest(password, stretches, salt, pepper)
        digest = pepper
        stretches.times { digest = self.secure_digest(salt, digest, password, pepper) }
        digest
      end

    private

      # Generate a SHA1 digest joining args. Generated token is something like
      #   --arg1--arg2--arg3--argN--
      def self.secure_digest(*tokens)
        ::Digest::SHA1.hexdigest('--' << tokens.flatten.join('--') << '--')
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 7 rubygems

Version Path
devise_sociable-0.1.0 vendor/bundle/gems/devise-1.2.1/lib/devise/encryptors/sha1.rb
devise-1.4.9 lib/devise/encryptors/sha1.rb
devise-1.4.8 lib/devise/encryptors/sha1.rb
devise-1.4.7 lib/devise/encryptors/sha1.rb
devise-1.4.5 lib/devise/encryptors/sha1.rb
devise-1.4.3 lib/devise/encryptors/sha1.rb
devise-1.4.2 lib/devise/encryptors/sha1.rb
devise-1.4.1 lib/devise/encryptors/sha1.rb
devise-1.3.4 lib/devise/encryptors/sha1.rb
devise-1.3.3 lib/devise/encryptors/sha1.rb
devise-1.3.2 lib/devise/encryptors/sha1.rb
devise-1.3.1 lib/devise/encryptors/sha1.rb
devise-1.3.0 lib/devise/encryptors/sha1.rb
devise-1.2.1 lib/devise/encryptors/sha1.rb
devise-1.2.0 lib/devise/encryptors/sha1.rb
devise-1.1.9 lib/devise/encryptors/sha1.rb
devise-jdguyot-1.2.rc3 lib/devise/encryptors/sha1.rb
devise-1.1.8 lib/devise/encryptors/sha1.rb
devise-1.2.rc2 lib/devise/encryptors/sha1.rb
devise-jdguyot-1.2.rc2 lib/devise/encryptors/sha1.rb