Module: Sinatra::Security::Password::Hashing
Instance Method Summary collapse
-
#check(password, crypted) ⇒ true, false
Checks the password against the serialized password.
-
#encrypt(password, salt = self.generate_salt) ⇒ String
Given any string generates a string which includes both the 128 character (SHA512) hash and the salt.
Instance Method Details
#check(password, crypted) ⇒ true, false
Checks the password against the serialized password.
89 90 91 92 93 |
# File 'lib/sinatra/security/password.rb', line 89 def check(password, crypted) hash, salt = unserialize(crypted) self.hash(password, salt) == hash end |
#encrypt(password, salt = self.generate_salt) ⇒ String
Given any string generates a string which includes both the 128 character (SHA512) hash and the salt.
By default the salt is a 64 character pseudo-random string.
70 71 72 |
# File 'lib/sinatra/security/password.rb', line 70 def encrypt(password, salt = self.generate_salt) serialize(hash(password, salt), salt) end |