Skip to main content
Module

x/simple_utility/src/pure/crypto.ts>cryptoEncrypt

Simplify processing for Deno.
Latest
function cryptoEncrypt
import { cryptoEncrypt } from "https://deno.land/x/simple_utility@v2.2.1/src/pure/crypto.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 key1 = await cryptoGenerateEncryptKey();
const key2 = await cryptoGenerateEncryptKey();
const encrypt = await cryptoEncrypt(bin, key1.pub, key2.key);
const decrypt = await cryptoDecrypt(encrypt, key2.pub, key1.key);

Parameters

data: Uint8Array
pub: Uint8Array
key: Uint8Array

Returns

Promise<Uint8Array>