Function aesGcmEncrypt

  • Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt(). (c) Chris Veness MIT Licence https://gist.github.com/chrisveness/43bcda93af9f646d083fad678071b90a Modified to work with Uint8Array and string content.

    Type Parameters

    • T extends string | Uint8Array

    Parameters

    • content: T

      Plaintext or Uint8 Buffer to be encrypted.

    • password: string | Uint8Array

      Plaintext or Uint8 Buffer Password to use to encrypt content.

    • Optional prefix: string | Uint8Array

      Optional prefix to prepend to the ciphertext.

    Returns Promise<T>

    Encrypted ciphertext. If content is a string, the ciphertext is a string. If content is a Uint8Array, the ciphertext is a new Uint8Array.

    Example

    const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
    aesGcmEncrypt('my secret text', 'pw').then(function(ciphertext) { console.log(ciphertext); });