Module: HealthCards::Encoding

Included in:
JWS
Defined in:
lib/health_cards/encoding.rb

Overview

Encoding utilities for producing JWS

Instance Method Summary collapse

Instance Method Details

#decode(data) ⇒ String

Decodes the provided data using url safe base 64

Parameters:

  • data (String)

    the data to be decoded

Returns:

  • (String)

    the decoded data



20
21
22
# File 'lib/health_cards/encoding.rb', line 20

def decode(data)
  Base64.urlsafe_decode64(data)
end

#encode(data) ⇒ String

Encodes the provided data using url safe base64 without padding

Parameters:

  • data (String)

    the data to be encoded

Returns:

  • (String)

    the encoded data



13
14
15
# File 'lib/health_cards/encoding.rb', line 13

def encode(data)
  Base64.urlsafe_encode64(data, padding: false).gsub("\n", '')
end