Skip to main content
Version: Current

encrypt

@rotorsoft/act-root


@rotorsoft/act-root / act-crypto/src / encrypt

Function: encrypt()

encrypt(payload, resolve_key): Promise<string>

Defined in: libs/act-crypto/src/envelope.ts:142

Encrypt a JSON-serializable value into a base64-framed string.

The payload is JSON.stringify-ed before encryption — callers holding raw bytes wrap them in a JSON-safe form (base64 string, tagged object) before calling.

Parameters​

payload​

unknown

Anything JSON.stringify can serialize. Callers filter null/undefined upstream when the storage layer treats absence specially.

resolve_key​

() => Promise<Buffer<ArrayBufferLike>>

Key resolver from makeKeyResolver.

Returns​

Promise<string>

Base64-encoded framed ciphertext suitable for a text or jsonb column.

Throws​

Error if payload is not JSON-serializable (undefined, a function, or a Symbol — anything JSON.stringify maps to undefined).