Skip to content

@pqc-sdk/core / encrypt

Function: encrypt()

encrypt(data, publicKey): Promise<Uint8Array<ArrayBufferLike>>

Hybrid encryption: encapsulates a secret with ML-KEM-768 (FIPS 203) and encrypts the data with AES-256-GCM using that secret. The result is a single self-contained Uint8Array that only decrypt can open.

Parameters

data

string | Uint8Array<ArrayBufferLike>

publicKey

PublicKey<"ml-kem-768">

Returns

Promise<Uint8Array<ArrayBufferLike>>

Example

ts
import { pqc } from '@pqc-sdk/core';

const pair = await pqc.keys.generate();
const ciphertext = await pqc.encrypt('sensitive data', pair.publicKey);