import { cryptoEncrypt } from "https://deno.land/x/simple_utility@v0.3.0/mod.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
const bin = await Deno.readFile("./file");
const key1 = await cryptoGenerateKey(true);
const key2 = await cryptoGenerateKey(true);
const converted = await cryptoEncrypt({
publicKey: key1.publicKey,
privateKey: key2.privateKey
}, bin);
const restored = await cryptoDecrypt({
publicKey: key2.publicKey,
privateKey: key1.privateKey
}, converted);
const bin = await Deno.readFile("./file"); const key1 = await cryptoGenerateKey(true); const key2 = await cryptoGenerateKey(true); const converted = await cryptoEncrypt({ publicKey: key1.publicKey, privateKey: key2.privateKey }, bin); const restored = await cryptoDecrypt({ publicKey: key2.publicKey, privateKey: key1.privateKey }, converted);
Parameters
unnamed 0: PortableCryptoKeyPair