• Encrypt a string as a secret storage item, using AES-CTR.

    Parameters

    • data: string

      the plaintext to encrypt

    • key: Uint8Array

      the encryption key to use as an input to the HKDF function which is used to derive the AES key for encryption. Obviously, the same key must be provided when decrypting.

    • name: string

      the name of the secret. Used as an input to the HKDF operation which is used to derive the AES key, so again the same value must be provided when decrypting.

    • OptionalivStr: string

      the base64-encoded initialization vector to use. If not supplied, a random one will be generated.

    Returns Promise<AESEncryptedSecretStoragePayload>

    The encrypted result, including the ciphertext itself, the initialization vector (as supplied in ivStr, or generated), and an HMAC on the ciphertext — all base64-encoded.