Skip to main content
Module

x/fastro/crypto/encrypt.ts

Fast and simple web application framework for deno
Go to Latest
File
export function encryptData( key: CryptoKey, plaintext: string,) { const data = new TextEncoder().encode(plaintext); return crypto.subtle.encrypt( { name: key.algorithm.name, iv: new Uint8Array(12) }, key, data, ).then((encryptedData) => { return btoa( String.fromCharCode(...new Uint8Array(encryptedData)), ); });}