Код: Выделить всё
async function download_file(folder, file) {
const response = await fetch(file.url);
const ciphertext = await response.arrayBuffer();
const iv = Uint8Array.fromBase64(file.iv);
const cleartext = await window.crypto.subtle.decrypt({name: "AES-GCM", iv: iv}, folder.key, ciphertext);
const blob = new Blob([cleartext], {type: file.type});
const url = URL.createObjectURL(blob);
const file_a = window.document.createElement("a");
file_a.innerText = file.name;
file_a.href = url;
file_a.download = file.name;
file_a.click();
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... btlecrypto
Мобильная версия