JsonWebToken.Format.Base64Url

Provide base64url encoding and decoding functions without padding, based upon standard base64 encoding and decoding functions that do use padding

see http://tools.ietf.org/html/rfc7515#appendix-C

Summary

decode(string)

Given a string encoded as url_encode64, add trailing “=” padding and return a decoded string

encode(string)

Given a string, return a url_encode64 string with all trailing “=” padding removed

Functions

decode(string)

Given a string encoded as url_encode64, add trailing “=” padding and return a decoded string

Example

iex> JsonWebToken.Format.Base64Url.decode("YmFy")
"bar"

The number of “=” padding characters that need to be added to the end of a url_encode64-encoded string without padding to turn it into one with padding is a deterministic function of the length of the encoded string.

encode(string)

Given a string, return a url_encode64 string with all trailing “=” padding removed

Example

iex> JsonWebToken.Format.Base64Url.encode("foo")
"Zm9v"