async function subtleEncryptData(data, password, cipher = 'aes-gcm') {
  const pwUtf8 = new TextEncoder().encode(password); // encode password as UTF-8
  const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8); // hash the password
  const iv = crypto.getRandomValues(new Uint8Array(12)); // get 96-bit random iv
  const alg = { name: cipher.toUpperCase(), iv: iv }; // specify algorithm to use
  const key = await crypto.subtle.importKey('raw', pwHash, alg, false, ['encrypt']); // generate key from pw

  const ctBuffer = await crypto.subtle.encrypt(alg, key, data); // encrypt data using key 
  return concatBuffers(iv, new Uint8Array(ctBuffer)); // ciphertext as byte array
}
Encrypts data using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
@param   {Uint8Array} data - Data to be encrypted.
@param   {String} password - Password to use to encrypt plaintext.
@param   {String} [cipher=aes-gcm] - Algorithm to use.
@returns {Uint8Array} Encrypted data.
@example const encryptedData = await dataEncrypt(uint8array, 'password');