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