Class: JWT::Base64 Private

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/base64.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base64 encoding and decoding

Class Method Summary collapse

Class Method Details

.url_decode(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Decode a string with URL-safe Base64 complying with RFC 4648.



18
19
20
21
22
23
24
# File 'lib/jwt/base64.rb', line 18

def url_decode(str)
  ::Base64.urlsafe_decode64(str)
rescue ArgumentError => e
  raise unless e.message == 'invalid base64'

  raise Base64DecodeError, 'Invalid base64 encoding'
end

.url_encode(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Encode a string with URL-safe Base64 complying with RFC 4648 (not padded).



12
13
14
# File 'lib/jwt/base64.rb', line 12

def url_encode(str)
  ::Base64.urlsafe_encode64(str, padding: false)
end