class PkiExpress::DigestAlgorithmAndValue

Attributes

algorithm[RW]
value[RW]

Public Class Methods

new(model) click to toggle source
# File lib/pki_express/digest_algorithm_and_value.rb, line 4
def initialize(model)
  @algorithm = nil
  @value = nil

  unless model.nil?
    value = model.fetch(:value)
    algorithm = model.fetch(:algorithm)
    if value.nil?
      raise 'The value was not set'
    end
    if algorithm.nil?
      raise 'The algorithm was not set'
    end

    @value = Base64.decode64(value).bytes
    @algorithm = DigestAlgorithm.get_instance_by_api_model(algorithm)
  end
end

Public Instance Methods

hex_value() click to toggle source
# File lib/pki_express/digest_algorithm_and_value.rb, line 23
def hex_value
  @value.map { |b| b.to_s(16).rjust(2,'0') }.join.upcase
end
hex_value=(value) click to toggle source
# File lib/pki_express/digest_algorithm_and_value.rb, line 27
def hex_value=(value)
  @value = [value].pack('H*').unpack('C*')
end