Skip to content

b64encode

b64encode(s: string | Uint8Array<ArrayBufferLike>): Uint8Array

Defined in: packages/pythonlib/src/base64.ts:59

Encode bytes-like object using Base64 and return bytes.

Parameters

ParameterTypeDescription
sstring | Uint8Array<ArrayBufferLike>Bytes to encode (Uint8Array or string)

Returns

Uint8Array

Base64 encoded Uint8Array

Example

const encoded = b64encode(new TextEncoder().encode("hello"))
console.log(new TextDecoder().decode(encoded)) // "aGVsbG8="