Module: Sinatra::Authentication::Cookies::Hashing
Instance Method Summary collapse
- #check?(user_id, ip, key, crypted) ⇒ Boolean
- #decrypt(crypted, key) ⇒ Object
- #encrypt(user_id, ip, key, salt = self.generate_salt) ⇒ Object
Instance Method Details
#check?(user_id, ip, key, crypted) ⇒ Boolean
18 19 20 21 |
# File 'lib/sinatra/authentication/cookies.rb', line 18 def check?(user_id, ip, key, crypted) hash, salt = unserialize(crypted) self.hash(user_id, ip, key, salt) == hash end |
#decrypt(crypted, key) ⇒ Object
14 15 16 |
# File 'lib/sinatra/authentication/cookies.rb', line 14 def decrypt(crypted, key) Encryptor.decrypt(crypted, :key => key) end |
#encrypt(user_id, ip, key, salt = self.generate_salt) ⇒ Object
9 10 11 12 |
# File 'lib/sinatra/authentication/cookies.rb', line 9 def encrypt(user_id, ip, key, salt = self.generate_salt) hash = serialize(hash(user_id, ip, key, salt), salt) { :hash => hash, :salt => salt } end |