Skip to content

Instantly share code, notes, and snippets.

@mnp291
mnp291 / crypto-aes-gcm.js
Created June 13, 2021 00:45 — 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');
@mnp291
mnp291 / browser.js
Created March 6, 2021 01:33 — forked from juliarose/browser.js
Basic browser interface
'use strict';
// browser utilities
const browser = chrome;
const tabs = browser.tabs;
const storage = browser.storage.sync || browser.storage.local;
const onMessage = browser.runtime.onMessage;
const browserLocalStorage = localStorage;