Module: JWE::Base64

Defined in:
lib/jwe/base64.rb

Overview

Base64 for JWE is slightly different from what ruby provides.

Class Method Summary collapse

Class Method Details

.jwe_decode(payload) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/jwe/base64.rb', line 8

def self.jwe_decode(payload)
  padlen = 4 - (payload.length % 4)
  if padlen < 4
    pad = '=' * padlen
    payload += pad
  end
  ::Base64.urlsafe_decode64(payload)
end

.jwe_encode(payload) ⇒ Object


4
5
6
# File 'lib/jwe/base64.rb', line 4

def self.jwe_encode(payload)
  ::Base64.urlsafe_encode64(payload).delete('=')
end