class TSS::Hasher

Hasher is responsible for managing access to the various one-way hash functions that can be used to validate a secret.

Constants

C
HASHES

Public Class Methods

byte_array(hash_key, str) click to toggle source
# File lib/tss/hasher.rb, line 93
def self.byte_array(hash_key, str)
  return [] if hash_key == 'NONE'
  HASHES[hash_key][:hasher].send(:digest, str).unpack('C*')
end
byte_string(hash_key, str) click to toggle source
# File lib/tss/hasher.rb, line 81
def self.byte_string(hash_key, str)
  return '' if hash_key == 'NONE'
  HASHES[hash_key][:hasher].send(:digest, str)
end
bytesize(hash_key) click to toggle source
# File lib/tss/hasher.rb, line 58
def self.bytesize(hash_key)
  HASHES[hash_key][:bytesize]
end
code(hash_key) click to toggle source
# File lib/tss/hasher.rb, line 29
def self.code(hash_key)
  HASHES[hash_key][:code]
end
codes() click to toggle source
# File lib/tss/hasher.rb, line 37
def self.codes
  HASHES.map do |_k, v|
    v[:code]
  end
end
codes_without_none() click to toggle source
# File lib/tss/hasher.rb, line 47
def self.codes_without_none
  HASHES.map do |_k, v|
    v[:code] if v[:code] > 0
  end.compact
end
hex_string(hash_key, str) click to toggle source
# File lib/tss/hasher.rb, line 69
def self.hex_string(hash_key, str)
  return '' if hash_key == 'NONE'
  HASHES[hash_key][:hasher].send(:hexdigest, str)
end
key_from_code(code) click to toggle source
# File lib/tss/hasher.rb, line 17
def self.key_from_code(code)
  return nil unless Hasher.codes.include?(code)
  HASHES.each do |k, v|
    return k if v[:code] == code
  end
end