Skip to main content
Module

x/simple_utility/mod.ts>cryptoEncrypt

Useful snippet collection.
Go to Latest
function cryptoEncrypt
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);

Parameters

data: Uint8Array