I have been working on a project where I need to download encrypted images and decrypt them using RNcryptor in a JavaScript web application, then display them within the HTML of my app. Everything is functioning perfectly except for when the images are larger in size, which causes the call stack to be exceeded.
Interestingly, this issue does not occur when transferring images between devices like the iPhone, but only happens when trying to send them to the web app. Specifically, I encounter this error with an iPhone 6+ device but not with any other devices.
Here is the function I am currently using to convert a byte array to a base64 string:
function encode(data)
{
var str = String.fromCharCode.apply(null,data);
return btoa(str).replace(/.{76}(?=.)/g,'$&\n');
}
I am wondering if there might be a more efficient way to convert the data without exceeding the call stack. Even if it sacrifices speed, I am open to exploring alternative approaches.