Class: SignatureVerifierUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-common/common/Utils.rb

Overview

Utility class for signature verification

Class Method Summary collapse

Class Method Details

.base64_decode(key) ⇒ Object



7
8
9
10
11
12
# File 'lib/ruby-common/common/Utils.rb', line 7

def self.base64_decode(key)
  if key.include? "-" or key.include? "_" then
    return Base64.urlsafe_decode64(key)
  end
  return Base64.decode64(key)
end

.character_to_int(value) ⇒ Object



3
4
5
# File 'lib/ruby-common/common/Utils.rb', line 3

def self.character_to_int(value)
  value.to_i
end

.encode(key, data) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ruby-common/common/Utils.rb', line 14

def self.encode(key, data)
  begin
    hmac = OpenSSL::HMAC.new(key, 'sha256')
    return hmac.update(data).digest
  rescue StandardError => e
    raise SignatureParseError, "Error encode data"
  end
end