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:122

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).