function encrypt
encrypt<Plain extends string>(plaintext: Plain): Promise<EnvKeyEncrypted<Plain>>

Encrypt a string value using AES-256-GCM via node:crypto (faster than Web Crypto for the small payloads this handles; output stays interoperable). Returns format: enc:1:$base64iv:$base64ciphertext Note: ciphertext includes the GCM auth tag appended.

Type Parameters

Plain extends string

Parameters

plaintext: Plain

Return Type

Promise<EnvKeyEncrypted<Plain>>

Usage

import { encrypt } from "docs/crypto.ts";