Skip to content

Instantly share code, notes, and snippets.

View Kirill-Vorobyev's full-sized avatar

Kirill Vorobyev Kirill-Vorobyev

View GitHub Profile
@Kirill-Vorobyev
Kirill-Vorobyev / crypto-aes-gcm.js
Created May 30, 2024 17:09 — forked from chrisveness/crypto-aes-gcm.js
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');