Class: SecureURI::Hasher
- Inherits:
-
Object
- Object
- SecureURI::Hasher
- Defined in:
- lib/secure_uri/hasher.rb
Overview
Placeholder class to make sure a hashing class is set before the class is used.
Required methods:
-
self.hash
The salt mechanism is there as most hashing implementations will need a shared secret.
Subclass this class to automagically set the hasher to your class.
Direct Known Subclasses
Class Attribute Summary collapse
-
.salt ⇒ Object
Lets us read the salt; defaulting to an empty string.
Class Method Summary collapse
-
.compare(hash, str) ⇒ Object
Takes a hash and a string.
-
.hash(str) ⇒ Object
Takes a string and hashes it.
-
.inherited(klass) ⇒ Object
Convenience method so subclassing Hasher automatically sets the new (sub)class as the Hasher class in SecureURI.
Class Attribute Details
.salt ⇒ Object
Lets us read the salt; defaulting to an empty string
17 18 19 |
# File 'lib/secure_uri/hasher.rb', line 17 def salt @salt || "" end |
Class Method Details
.compare(hash, str) ⇒ Object
Takes a hash and a string. Hashes the string using self#hash and compares to the hash passed in.
Returns True or False
32 33 34 |
# File 'lib/secure_uri/hasher.rb', line 32 def compare hash, str hash == self.hash(str) end |
.hash(str) ⇒ Object
Takes a string and hashes it
Returns String
24 25 26 |
# File 'lib/secure_uri/hasher.rb', line 24 def hash str raise "hash method needs to be overridden" end |