Sha256: 84df70507bd439c1178b20777b0ab333d347c86941c46736004d4f80126d295e
Contents?: true
Size: 977 Bytes
Versions: 4
Compression:
Stored size: 977 Bytes
Contents
module Entrance module Ciphers module SHA1 require 'digest/sha1' JOIN_STRING = '--' def self.match?(stored, given, salt = nil) stored === encrypt(given, salt) end # same logic as restful authentication def self.encrypt(password, salt) digest = Entrance.config.secret raise "Secret not set!" if digest.blank? Entrance.config.stretches.times do str = [digest, salt, password, Entrance.config.secret].join(JOIN_STRING) digest = Digest::SHA1.hexdigest(str) end digest end end module BCrypt require 'bcrypt' # https://github.com/codahale/bcrypt-ruby def self.match?(stored, given, salt = nil) ::BCrypt::Password.new(stored) == given # ::BCrypt::Password.new(stored) == encrypt(given) end def self.encrypt(password, salt = nil) ::BCrypt::Password.create(password) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
entrance-0.3.2 | lib/entrance/ciphers.rb |
entrance-0.3.0 | lib/entrance/ciphers.rb |
entrance-0.2.5 | lib/entrance/ciphers.rb |
entrance-0.2.4 | lib/entrance/ciphers.rb |