0

I'm not sure why, because I'm using this on chrome without any problems. But I'm trying to create a blob with base64 content and for some reason on IE 11, it doesn't work, and on console I get 'InvalidStateError' at the line of the contructor:

 var blob = new Blob([encrypted], {type : 'application/octet-stream'});

The 'encrypted' variable as I said, have base64 encrypted string from CryptoJS. I believe that's not the problem (the content of the variable)... What to do here guys?

  • Is `encrypted` a typed array, or just a string you put in a regular array ? – adeneo Feb 05 '15 at 23:16
  • Anyway, try -> `var blob = new Blob([new Uint8Array([encrypted])], { type: 'application/octet-stream' });` – adeneo Feb 05 '15 at 23:17
  • I believe it's a string. Here is how it's declared: `var encrypted = CryptoJS.AES.encrypt(e.target.result, password);` ... for what I know, this returns me a base64 string. – Petrus Ananias Feb 05 '15 at 23:17
  • Wait... The error is solved, let me just make a few tests... – Petrus Ananias Feb 05 '15 at 23:19
  • I think it should be a typed array, even if other browsers seem to work? You got an error when using `Uint8Array` as well? Was it the same error ? – adeneo Feb 05 '15 at 23:20
  • Your tip solved the IE error, but the blob is getting a 1byte file only =\... – Petrus Ananias Feb 05 '15 at 23:26
  • Aha, you can't just stick strings in an `Uint8Array`, if there's a way to get a buffer from crypto, that could probably used, and here's a function that will actually create a typed array from a base64 string, you could use that -> https://gist.github.com/borismus/1032746 – adeneo Feb 05 '15 at 23:29
  • And there are ways in cryptoJS as well, adding an additional script for typed arrays -> http://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer – adeneo Feb 05 '15 at 23:32
  • I don't think `encrypted` is a string, try doing `encrypted.toString()` – Musa Feb 06 '15 at 00:16
  • on the Blob constructor? – Petrus Ananias Feb 06 '15 at 00:24
  • And it worked again Musa... You are my life savior... – Petrus Ananias Feb 06 '15 at 01:18

0 Answers0