class Realize::Format::Sha256

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.

Constants

DEFAULT_ENCODING_FORMAT

Attributes

encoding_format[R]

Public Class Methods

new(encoding_format: DEFAULT_ENCODING_FORMAT) click to toggle source
# 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

Public Instance Methods

transform(_resolver, value, _time, _record) click to toggle source
# File lib/realize/format/sha256.rb, line 33
def transform(_resolver, value, _time, _record)
  Digest::SHA256.send(sha_method, value.to_s)
end

Private Instance Methods

sha_method() click to toggle source
# File lib/realize/format/sha256.rb, line 39
def sha_method
  case encoding_format
  when HEX
    :hexdigest
  when BASE64
    :base64digest
  end
end