Back to Jose

Function: decode()

docs/util/base64url/functions/decode.md

6.2.91.2 KB
Original Source

Function: decode()

šŸ’— Help the project

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.

ā–ø decode(input): Uint8Array

Decodes a Base64URL encoded input.

These functions are exported (as the base64url namespace) from the main 'jose' module entry point as well as from its subpath export 'jose/base64url'.

Parameters

ParameterTypeDescription
inputstring | Uint8ArrayBase64URL encoded input, as a string or its UTF-8 bytes.

Returns

Uint8Array

The decoded bytes.

Example

js
const decoded = jose.base64url.decode('SGVsbG8gV29ybGQh')

Throws

When the input is not correctly Base64URL encoded. Standard Base64 input (i.e. containing + or /) is rejected.