I need to encrypt some text in the browser to be stored server side. After a little research I decided to use the SubtleCrypto API. I created the the crypto key using the following code:
window.crypto.subtle
.generateKey(
{
name: "RSA-OAEP",
modulusLength: 4096,
publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-256",
},
true,
["encrypt", "decrypt"]
)
My initial testing was successful but later I discovered that any text longer than 446 bytes is failing. Which looks like to be expected according to this answer. I am no crypto expert so what should I do to encrypt larger amounts of data (low megabytes). Choose a different algorithm, or split the data in chunks etc?