Back to Jose

Function: encode()

docs/util/base64url/functions/encode.md

6.2.12988 B
Original Source

Function: encode()

šŸ’— 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.

ā–ø encode(input): string

Encodes unpadded base64url; strings are first encoded as UTF-8.

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 | Uint8ArrayBytes or a string to encode. Strings are first encoded as UTF-8.

Returns

string

The unpadded base64url representation of the input.

Example

js
const encoded = jose.base64url.encode('Hello World!')