Sha256: 9b2b5d79510a65331a016253d79b5dab0b005de71f966992c9393141f40da43c

Contents?: true

Size: 725 Bytes

Versions: 23

Compression:

Stored size: 725 Bytes

Contents

require "digest/sha2"

module Devise
  module Encryptors
    # = Sha512
    # Uses the Sha512 hash algorithm to encrypt passwords.
    class Sha512 < 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 = self.secure_digest(salt, digest, password, pepper) }
        digest
      end

    private

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

Version data entries

23 entries across 23 versions & 5 rubygems

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