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

Decrypt binary. Algorithm use is "AES-GCM" with 256 bits key, 128 bits tag and 96 bits IV. IV is read from head of 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>