webcrypto-example icon indicating copy to clipboard operation
webcrypto-example copied to clipboard

encrypting more than ~50kb text fails

Open jmattthew opened this issue 4 years ago • 1 comments

If you input more than ~50kb of text into the input box, it fails with the error message "Error - RangeError: Maximum call stack size exceeded". Sorry, I'm not sure if this is a bug, setting, or a limitation of web crypto API

jmattthew avatar Nov 21 '20 20:11 jmattthew

I found a solution that fixes this size limit issue, and everything seems to work with this. But I don't know if this would have any unintended consequences.

const buff_to_base64 = function(buff) {
    return btoa(new Uint8Array(buff).reduce(function (data, byte) {
        return data + String.fromCharCode(byte);
    }, ''));
}

jmattthew avatar Nov 22 '20 02:11 jmattthew