Sha256: 271008b7eb367630a487715426d78cbfe095bca5e0027a0a2e639a138e45cd3a

Contents?: true

Size: 400 Bytes

Versions: 2

Compression:

Stored size: 400 Bytes

Contents

module JWE
  # Base64 for JWE is slightly different from what ruby provides.
  module Base64
    def self.jwe_encode(payload)
      ::Base64.urlsafe_encode64(payload).delete('=')
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jwe-0.4.0 lib/jwe/base64.rb
jwe-0.3.1 lib/jwe/base64.rb