<pre>req.open("GET", name, true); req.responseType = "blob"; req.onreadystatechange = function () { if (req.readyState == req.DONE) { var blobResponse = req.response; var fileReader = new FileReader(); fileReader.onload = function() { var worker = new Worker('worker_file.js'); var binaryArrayOut = new Array(); var arrayBuffer = this.result;; var fileNameOut; var currentCompletion = 0; var lengthLeft = getSize.size - 1; var perInterval = 100/(lengthLeft/5242880); var getSize = new Blob([arrayBuffer]); var currentStart = 0; worker.onmessage = function(e) { binaryArrayOut.push(e.data.fileObject); fileNameOut = e.data.filenameToSaveAs; console.log(fileNameOut); } var postDataVar; var postLengthVar; var binaryArray; if(lengthLeft - (currentStart + 5242880) < 0) { postLengthVar = lengthLeft - currentStart; binaryArray = arrayBuffer.slice(currentStart); postDataVar = new Blob([binaryArray]); currentStart = lengthLeft; } else { postLengthVar = lengthLeft - (currentStart + 5242880); binaryArray = arrayBuffer.slice(currentStart, currentStart + 5242880); postDataVar = new Blob([binaryArray]); currentStart = currentStart + 5242880; } worker.postMessage( {'blobResponse': postDataVar3, 'fileName': fileName, 'password': passwd }); } fileReader.readAsArrayBuffer(new Blob([blobResponse])); } } req.send(); }
// worker_file.js self.onmessage = function(e) { loadFile(e.data.blobResponse, e.data.fileName, e.data.password) } Got this file, fullfilename and password to call encrypt functions via loadFile function. function encrypt( file, fullfilename, passwordIn) { // Init new instance of FileReader var reader = new FileReader(); // Operate on data at load time reader.onload = function(f) { // Encrypt with AES256 against password // use built in CrytoJS AES code to encrypt var encrypted = CryptoJS.AES.encrypt(f.target.result, passwordIn) // Create file for download. This is the encrypted file createFileDownload(encrypted); }; reader.readAsDataURL(file); } Now, the issue is it does generate an encrypted file and downloads it. But, when I checked that encrypted file to decrypt using some other online decryption apps with the same passphrase. It does not give correct decryption file which means encryption file has some issue or maybe not encrypt in a correct way that is why cannot decrypt it. But I do not understand where is the issue exactly. Could any one help me with this? What I have tried: I wrote the code again 2 times and execute single commands, but nothing found.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)