Module: Ya::Digest
- Defined in:
- lib/ya/digest.rb
Constant Summary collapse
- RANDOM_SEED =
9999999999999999
Class Method Summary collapse
Class Method Details
.random_hash ⇒ Object
13 14 15 |
# File 'lib/ya/digest.rb', line 13 def random_hash ::Digest::SHA1.hexdigest("#{Time.now}-#{rand RANDOM_SEED}") end |
.salt_and_hash(password) ⇒ Object
17 18 19 20 21 |
# File 'lib/ya/digest.rb', line 17 def salt_and_hash(password) salt = random_hash hash = salt_password(salt, password) { :salt => salt, :hash => hash } end |
.salt_password(salt, password) ⇒ Object
8 9 10 11 |
# File 'lib/ya/digest.rb', line 8 def salt_password(salt, password) raise ArgumentError, 'salt can not be nil' unless salt ::Digest::SHA1.hexdigest("#{salt}---#{password}") end |