Class: H::Builder
- Inherits:
-
Object
- Object
- H::Builder
- Defined in:
- lib/h.rb
Overview
Builder handles the creation of salted password hashes using SHA-256
Instance Attribute Summary collapse
-
#secret ⇒ String
readonly
The secret salt used for hashing.
Instance Method Summary collapse
-
#call(value) ⇒ String
Generate a salted hash of the provided value.
-
#initialize(secret) ⇒ Builder
constructor
Initialize a new Builder with a secret salt.
Constructor Details
#initialize(secret) ⇒ Builder
Initialize a new Builder with a secret salt
17 18 19 20 21 |
# File 'lib/h.rb', line 17 def initialize(secret) @secret = String(secret) freeze end |
Instance Attribute Details
#secret ⇒ String (readonly)
Returns the secret salt used for hashing.
13 14 15 |
# File 'lib/h.rb', line 13 def secret @secret end |
Instance Method Details
#call(value) ⇒ String
Generate a salted hash of the provided value
26 27 28 |
# File 'lib/h.rb', line 26 def call(value) ::Digest::SHA256.base64digest("#{value}++#{secret}") end |