Class: PHash
- Inherits:
-
Object
- Object
- PHash
- Defined in:
- lib/p_hash.rb
Instance Attribute Summary collapse
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#hash_function ⇒ Object
readonly
Returns the value of attribute hash_function.
-
#key_length ⇒ Object
readonly
Returns the value of attribute key_length.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
- #base64digest ⇒ Object
- #hexdigest ⇒ Object
-
#initialize(hash_function, secret, seed, key_length = 32) ⇒ PHash
constructor
A new instance of PHash.
Constructor Details
#initialize(hash_function, secret, seed, key_length = 32) ⇒ PHash
Returns a new instance of PHash.
7 8 9 10 11 12 13 |
# File 'lib/p_hash.rb', line 7 def initialize(hash_function, secret, seed, key_length = 32) @hash_function = hash_function @secret = secret @seed = seed @key_length = key_length calculate_digest end |
Instance Attribute Details
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
5 6 7 |
# File 'lib/p_hash.rb', line 5 def digest @digest end |
#hash_function ⇒ Object (readonly)
Returns the value of attribute hash_function.
5 6 7 |
# File 'lib/p_hash.rb', line 5 def hash_function @hash_function end |
#key_length ⇒ Object (readonly)
Returns the value of attribute key_length.
5 6 7 |
# File 'lib/p_hash.rb', line 5 def key_length @key_length end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
5 6 7 |
# File 'lib/p_hash.rb', line 5 def secret @secret end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
5 6 7 |
# File 'lib/p_hash.rb', line 5 def seed @seed end |
Instance Method Details
#base64digest ⇒ Object
19 20 21 |
# File 'lib/p_hash.rb', line 19 def base64digest @base64digest ||= Base64.strict_encode64(digest) end |
#hexdigest ⇒ Object
15 16 17 |
# File 'lib/p_hash.rb', line 15 def hexdigest @hexdigest ||= digest.unpack('H*').first end |