Class: H256::Builder
- Inherits:
-
Object
- Object
- H256::Builder
- Defined in:
- lib/h256.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 hex-encoded 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
20 21 22 23 24 |
# File 'lib/h256.rb', line 20 def initialize(secret) @secret = String(secret) freeze end |
Instance Attribute Details
#secret ⇒ String (readonly)
Returns the secret salt used for hashing.
16 17 18 |
# File 'lib/h256.rb', line 16 def secret @secret end |
Instance Method Details
#call(value) ⇒ String
Generate a hex-encoded salted hash of the provided value
29 30 31 |
# File 'lib/h256.rb', line 29 def call(value) ::Digest::SHA256.hexdigest("#{value}++#{secret}") end |