🔐 Encodes bytes to a Base64 string.

Syntax

TypeScript
import { encodeBase64, stringToBytes } from '@opentf/std';

encodeBase64(bytes: Uint8Array | ArrayBuffer): string

Parameters

  • bytes: The bytes to encode.

Returns

The Base64 encoded string.

Examples

TypeScript
encodeBase64(new Uint8Array([72, 101, 108, 108, 111])) //=> 'SGVsbG8='

For text, compose with stringToBytes:

TypeScript
encodeBase64(stringToBytes('Hello')) //=> 'SGVsbG8='
Last updated on
Edit this page