Module: Sigstore::Internal::Util

Defined in:
lib/sigstore/internal/util.rb

Class Method Summary collapse

Class Method Details

.base64_decode(string) ⇒ Object



47
48
49
# File 'lib/sigstore/internal/util.rb', line 47

def base64_decode(string)
  string.unpack1("m0")
end

.base64_encode(string) ⇒ Object



43
44
45
# File 'lib/sigstore/internal/util.rb', line 43

def base64_encode(string)
  [string].pack("m0")
end

.hash_algorithm_name(algorithm) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sigstore/internal/util.rb', line 22

def hash_algorithm_name(algorithm)
  case algorithm
  when Common::V1::HashAlgorithm::SHA2_256
    "sha256"
  when Common::V1::HashAlgorithm::SHA2_384
    "sha384"
  when Common::V1::HashAlgorithm::SHA2_512
    "sha512"
  else
    raise ArgumentError, "Unrecognized hash algorithm #{algorithm}"
  end
end

.hex_decode(string) ⇒ Object



39
40
41
# File 'lib/sigstore/internal/util.rb', line 39

def hex_decode(string)
  [string].pack("H*")
end

.hex_encode(string) ⇒ Object



35
36
37
# File 'lib/sigstore/internal/util.rb', line 35

def hex_encode(string)
  string.unpack1("H*")
end