base64url

Decodes the given Base64URL back into a string.

Type signature

(text: string, context?: DecodeContext) => string

Examples

decode("PDw_Pz8-Pg");
// ⇒ "<<???>>"
Try in REPL

Questions

  • How to decode Base64URL?

TypeScript sourceJavaScript source

Decodes the given Base64URL back into a byte array.

Type signature

(text: string, context?: DecodeContext) => number[]

Examples

decodeBytes("w4Jnw6vCp20-bBsQfA");
// ⇒ [0xc2, 0x67, 0xeb, 0xa7, 0x6d, 0x3e, 0x6c, 0x1b, 0x10, 0x7c]
Try in REPL

Questions

  • How to decode Base64URL into a byte array?

TypeScript sourceJavaScript source

Encodes the given string into Base64URL.

Type signature

(text: string, context?: EncodeContext) => string

Examples

encode("<<???>>");
// ⇒ "PDw_Pz8-Pg"
Try in REPL

Questions

  • How to encode a string as Base64URL?

TypeScript sourceJavaScript source

Encodes the given bytes into Base64URL.

Type signature

(bytes: number[], context?: EncodeContext) => string

Examples

encodeBytes([
  0xc2, 0x67, 0xeb, 0xa7, 0x6d,
  0x3e, 0x6c, 0x1b, 0x10, 0x7c,
]);
// ⇒ "w4Jnw6vCp20-bBsQfA"
Try in REPL

Questions

  • How to encode bytes as Base64URL?

TypeScript sourceJavaScript source

Converts Base64 string into Base64URL one.

Type signature

(base64: string) => string

Examples

fromBase64("PDw/Pz8+Pg==");
// ⇒ "PDw_Pz8-Pg"
Try in REPL

Questions

  • How to convert Base64 to Base64URL?

TypeScript sourceJavaScript source

Converts Base64URL string into Base64 one.

Type signature

(base64Url: string) => string

Examples

toBase64("PDw_Pz8-Pg");
// ⇒ "PDw/Pz8+Pg=="
Try in REPL

Questions

  • How to convert Base64URL to Base64?

TypeScript sourceJavaScript source