Attempting to generate an AES-CBC scratch key for message encryption. The following code is used to generate and retrieve the key:
const key = await crypto.subtle.generateKey(
{
name: "AES-CBC",
length: 256,
},
true,
["encrypt", "decrypt"]
);
const secretKey = await crypto.subtle.exportKey('jwk', key)
Using the resulting secret key to encrypt messages on the
Encountering an issue: The length of the secret key should be 32 for a 256-bit key size
Attempted to obtain the key in Uint8Array and convert it to base64, but unsuccessful.
Requirement is to generate an AES secret key, encrypt the message using it with window.crypto, and enable decryption without using window.crypto later.
Uncertainty about what to do with the Uint8Array retrieved from exportKey.