Sha256: 1899645cfd9429e2fbc4e0c04a6b6e8bf0be4c5525a91855ef3807dbe9076561

Contents?: true

Size: 791 Bytes

Versions: 10

Compression:

Stored size: 791 Bytes

Contents

require "digest/sha1"

module Devise
  module Encryptable
    module Encryptors
      # = Sha1
      # Uses the Sha1 hash algorithm to encrypt passwords.
      class Sha1 < Base
        # Generates 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
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
devise-encryptable-0.2.0 lib/devise/encryptable/encryptors/sha1.rb
devise-encryptable-0.1.2 lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/devise-encryptable-0.1.1/lib/devise/encryptable/encryptors/sha1.rb
devise-encryptable-0.1.1 lib/devise/encryptable/encryptors/sha1.rb
devise-encryptable-0.1.0 lib/devise/encryptable/encryptors/sha1.rb