Class: Realize::Format::Sha256
- Inherits:
-
Object
- Object
- Realize::Format::Sha256
- Includes:
- EncodingFormat
- Defined in:
- lib/realize/format/sha256.rb
Overview
Convert the value into a SHA256 encoded string. There are two main encoding formats: hex or base64. By default, the value will be hexidecimal encoded.
Defined Under Namespace
Modules: EncodingFormat
Constant Summary collapse
- DEFAULT_ENCODING_FORMAT =
HEX
Constants included from EncodingFormat
EncodingFormat::BASE64, EncodingFormat::HEX
Instance Attribute Summary collapse
-
#encoding_format ⇒ Object
readonly
Returns the value of attribute encoding_format.
Instance Method Summary collapse
-
#initialize(encoding_format: DEFAULT_ENCODING_FORMAT) ⇒ Sha256
constructor
A new instance of Sha256.
- #transform(_resolver, value, _time, _record) ⇒ Object
Constructor Details
#initialize(encoding_format: DEFAULT_ENCODING_FORMAT) ⇒ Sha256
Returns a new instance of Sha256.
27 28 29 30 31 |
# File 'lib/realize/format/sha256.rb', line 27 def initialize(encoding_format: DEFAULT_ENCODING_FORMAT) @encoding_format = EncodingFormat.const_get(encoding_format.to_s.upcase.to_sym) freeze end |
Instance Attribute Details
#encoding_format ⇒ Object (readonly)
Returns the value of attribute encoding_format.
25 26 27 |
# File 'lib/realize/format/sha256.rb', line 25 def encoding_format @encoding_format end |
Instance Method Details
#transform(_resolver, value, _time, _record) ⇒ Object
33 34 35 |
# File 'lib/realize/format/sha256.rb', line 33 def transform(_resolver, value, _time, _record) Digest::SHA256.send(sha_method, value.to_s) end |