function hybridEncrypt
hybridEncrypt(
plaintext: string,
publicKey: CryptoKey,
): Promise<string>

Encrypt data using hybrid encryption (RSA + AES)

  • Generate random AES key
  • Encrypt data with AES-GCM
  • Encrypt AES key with RSA public key Returns format: hyb:1:$base64WrappedKey:$base64iv:$base64ciphertext

Parameters

plaintext: string
publicKey: CryptoKey

Return Type

Promise<string>

Usage

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