← All packages

@lacspace/crypto

v1.1.3Security Kit0 deps

Safe, boring cryptography over Web Crypto — authenticated AES-256-GCM, PBKDF2 key derivation, SHA-256, HMAC, secure random and constant-time compare. Isomorphic (Node, edge, browser, RN).

npm i @lacspace/crypto

Usage

crypto.ts
import { generateKey, encrypt, decrypt } from "@lacspace/crypto";

const key = generateKey();                 // 256-bit base64url key — store securely
const blob = await encrypt("card: 4242…", key);
// "v1:<iv>:<ciphertext+tag>"  — safe to store in Mongo / S3
const plain = await decrypt(blob, key);    // "card: 4242…"

Exports 19

KeyringconstantTimeEqualdecryptdecryptBytesdecryptWithPasswordderiveBitsdigestencryptencryptWithPasswordfromBase64urlfromHexgenerateKeyhkdfhmachmacVerifyrandomBytessha256toBase64urltoHex

Keywords

cryptoaesaes-256-gcmencryptionweb-cryptopbkdf2

More in Security Kit