I need to AES encrypt fileupload images with javascript before storing to the server but I'm running into LONGTEXT limitations when trying to store as custom field in MySQL. That method involved converting image to base64 and then encrypting.
I'm looking for a method to achieve the smallest string possible from that image upload before encrypting. Or at the very least how to reduce the image under a specified byte maximum.
<input id="foo" type="file" />
Encrypt with CryptoJS
$(document).on("change", "#foo", function() {
var chatImg = $(this).val();
// COMPRESS IMAGE
var keyAES = "123456789";
var eImg = CryptoJS.AES.encrypt(chatImg, keyAES).toString();
console.log(eImg);
});
Note: I've searched far and wide for a solution but the only ones I found involved set image widths/heights