Skip to main content
Module

x/simple_utility/mod.ts>cryptoEncrypt

Simplify processing for Deno.
Latest
function cryptoEncrypt
import { cryptoEncrypt } from "https://deno.land/x/simple_utility@v2.1.0/mod.ts";

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

Examples

Example 1

const bin = await Deno.readFile("./file");
const k1 = await cryptoGenerateEncryptKey();
const k2 = await cryptoGenerateEncryptKey();
const cipher = await cryptoEncrypt(bin, {
    publicKey: k1.publicKey,
    privateKey: k2.privateKey
});
const decrypt = await cryptoDecrypt(cipher, {
    publicKey: k2.publicKey,
    privateKey: k1.privateKey
});

Parameters

data: Uint8Array

Returns

Promise<Uint8Array>