Sha256: 1a8e9e2101c037ef9d2af1da7536160d86b721bc6b44f84dda0e550b9f1d500b

Contents?: true

Size: 758 Bytes

Versions: 15

Compression:

Stored size: 758 Bytes

Contents

require 'digest/sha1'

module Authentication

  # Generating a hash is a common task across many authentication
  # modules. This mixin makes the task easier.
  module HashHelper
    protected

    # Will hash the given string based on the given salt. The default
    # salt is the site salt. This is defined by the constant
    # AUTHENTICATION_SALT. If not defined then the installation
    # directory of the application will be used as the site salt.
    def hash_string(string, salt=site_salt)
      Digest::SHA1.hexdigest("#{salt}---#{string}")
    end

    private

    # Will retrieve the site salt.
    def site_salt
      return AUTHENTICATION_SALT if Object.const_defined? 'AUTHENTICATION_SALT'
      File.expand_path Rails.root
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.3.1 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.3.0 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.2.4 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.2.3 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.2.2 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.2.1 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.2.0 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.1.4 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.1.3 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.1.2 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.1.1 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.1.0 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva_user-0.0.1 vendor/gems/authentication/lib/authentication/hash_helper.rb
adva-0.0.1 adva_user/vendor/gems/authentication/lib/authentication/hash_helper.rb