Skip to main content
Go to Latest
function pubkeyEncrypt
import { pubkeyEncrypt } from "https://deno.land/x/simple_utility@v1.3.6/mod.universal.ts";

Encrypt binary. Algorithm use is "AES-GCM" with 256 bits key, 128 bits tag and 96 bits IV. IV is prepended to cipher.

Examples

Example 1

const bin = await Deno.readFile("./file");
const key1 = await pubkeyGen("ECDH");
const key2 = await pubkeyGen("ECDH");
const converted = await pubkeyEncrypt({
    publicKey: key1.publicKey,
    privateKey: key2.privateKey
}, bin);
const restored = await pubkeyDecrypt({
    publicKey: key2.publicKey,
    privateKey: key1.privateKey
}, converted);

Parameters

data: Uint8Array

Returns

Promise<Uint8Array>