Module: Entrance::Ciphers::SHA1
- Defined in:
- lib/entrance/ciphers.rb
Constant Summary collapse
- JOIN_STRING =
'--'
Class Method Summary collapse
-
.encrypt(password, salt) ⇒ Object
same logic as restful authentication.
- .match?(stored, given, salt = nil) ⇒ Boolean
Class Method Details
.encrypt(password, salt) ⇒ Object
same logic as restful authentication
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/entrance/ciphers.rb', line 15 def self.encrypt(password, salt) digest = Entrance.config.secret raise "Secret not set!" if digest.nil? or digest.strip == '' Entrance.config.stretches.times do str = [digest, salt, password, Entrance.config.secret].join(JOIN_STRING) digest = Digest::SHA1.hexdigest(str) end digest end |
.match?(stored, given, salt = nil) ⇒ Boolean
10 11 12 |
# File 'lib/entrance/ciphers.rb', line 10 def self.match?(stored, given, salt = nil) stored === encrypt(given, salt) end |