JOSE Base64

JOSE Base64 is defined as:

  • URL-safe Base64
  • padding stripped
josepy.b64.b64encode(data: bytes) → bytes[source]

JOSE Base64 encode.

Parameters:data (bytes) – Data to be encoded.
Returns:JOSE Base64 string.
Return type:bytes
Raises:TypeError – if data is of incorrect type
josepy.b64.b64decode(data: bytes) → bytes[source]

JOSE Base64 decode.


data (bytes or unicode) – Base64 string to be decoded. If it’s unicode, then only ASCII characters are allowed.


Decoded data.

Return type:


  • TypeError – if input is of incorrect type
  • ValueError – if input is unicode with non-ASCII characters