diff --git a/src/public/js/download.js b/src/public/js/download.js index cbf4b14..e891e30 100644 --- a/src/public/js/download.js +++ b/src/public/js/download.js @@ -35,9 +35,9 @@ const main = () => { ); // Send the file to the user - const blob = new Blob([decrypted_file], { - type: "application/json", - }); + const blob = new Blob([ + atob(decrypted_file.split(";base64,").pop()), + ]); const url = URL.createObjectURL(blob); download(url, decrypted_filename); } else { diff --git a/src/public/js/index.js b/src/public/js/index.js index ba59f9b..d96ef9b 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -70,7 +70,10 @@ const update = (element, text, tag = undefined) => { * @param file File to send */ const send = (file, element) => { - file.text().then((content) => { + let reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => { + const content = reader.result.split(";base64,").pop(); const req = new XMLHttpRequest(); element = update(element, "Génération des clefs...", "H3"); @@ -135,5 +138,5 @@ const send = (file, element) => { } }; }); - }); + }; };