Function aesGcmDecrypt

  • Decrypts ciphertext encrypted with aesGcmEncrypt() using supplied password. (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

    • ciphertext: T

      Ciphertext to be decrypted.

    • password: string | Uint8Array

      Password to use to decrypt ciphertext.

    Returns Promise<T>

    Decrypted content. If ciphertext is a string, the plaintext is a string. If ciphertext is a Uint8Array, the plaintext is a new Uint8Array.

    Example

    const plaintext = await aesGcmDecrypt(ciphertext, 'pw');
    aesGcmDecrypt(ciphertext, 'pw').then(function(plaintext) { console.log(plaintext); });