Subtle Crypto Algorithm Choice 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: &quot;RSA-OAEP&quot;,
                modulusLength: 4096,
                publicExponent: new Uint8Array([1, 0, 1]),
                hash: &quot;SHA-256&quot;,
            },
            true,
            [&quot;encrypt&quot;, &quot;decrypt&quot;]
        )

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?
RSA can not directly encrypt large data.
You need to generate a random key for a symmetric cipher (secure random), encrypt the large data with this key using a secure mode (e.g GCM).
encrypt the key with your RSA public key,
prepend encrypted key to encrypted data.
store.
This is just for understanding of what goes on, you should look for a library which does as much of this together as possible from a reputable source, start with libsodium which I believe has a pure JS implementation.