description |
---|
Decrypt Data with the Advanced Encryption Standard (AES) |
The decryptDatawithAES
performs symmetric encryption using the Advanced Encryption Standard (AES), specifically the Galois/ Counter Mode (GCM).
The AES
key and the random initialized vector (iv
) used at the time of encryption are needed to decrypt the data.
The iv
is part of the combinedArrayBuffer
returned as the encrypted data from the encryptDataWithAES
function. The decryptDataWithAES
functions splits this into the iv
and actual encryptedData
on the backend before decrypting the latter.
The function is called as follows:
import { decryptDatawithAES } from 'arweavekit/encryption';
const decryptedDataObject = await decryptDatawithAES({params});
The following params are available for this function and they must be passed in as an object:
data: ArrayBuffer
: The combination of the random initialized vector prepended to the encrypted data as anArrayBuffer
generated at the time of encryption.key: string
: The encryption key generated at the time of data encryption usingAES-GCM
and used for encrypting the data.
Example
const decryptedDataObject = await decryptDatawithAES({
data: ArrayBuffer,
key: string,
});
This encrypts the provided ArrayBuffer
using the AES-GCM
encryption method.
The function call returns the following data:
{
rawEncryptedKeyAsBase64: Base64 string,
combinedArrayBuffer: ArrayBuffer,
}
decryptedData: ArrayBuffer
: The decrypted data returned as anArrayBuffer
.