Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
javascript aes files result input type readAsDataURL () correct url format that can be displayed in the browser

Javascript easily encrypted text files but in the case of images it does not give me result I already tried with the input type readAsDataURL () and it is great how in the data output once decrypted it shows the connection in the correct url format that can be displayed in the browser but I don't know how to convert the string into a file

<script type="module"> /* file encryption/decryption */
    document.addEventListener('DOMContentLoaded', function(event) {
        document.getElementById('src-file').onchange = function() {
            const file = this.files[0];
            document.querySelector('#progress').removeAttribute('value');
            const t1 = performance.now();
            var reader = new FileReader();
            reader.readAsText(file, 'utf-8');
            reader.onload = function() {
            document.querySelector('#progress').value = 100;
            var password = document.querySelector('#password').value;
            var bits = 256;
            var plaintext = reader.result;
            var ciphertext = AesCtr.encrypt(plaintext, password, bits);
            var blob = new Blob([ciphertext], { type: 'text/plain' });
            saveAs(blob, file.name + '.enc');
            document.querySelector('#progress').value = 0;
            const t2 = performance.now();
            const t = ((t2-t1)/1000).toFixed(3)+'s';
            document.querySelector('#decrypt-file-time').textContent = t;
            }
}

        document.querySelector('#enc-file').onchange = function() {
            const file = this.files[0];
            document.querySelector('#progress').removeAttribute('value');
            const t1 = performance.now();
            var reader = new FileReader();
            reader.readAsText(file, 'iso-8859-1');
            reader.onload = function() {
            document.querySelector('#progress').value = 100;
            var password = document.querySelector('#password').value;
            var bits = 256;
            var ciphertext = reader.result;
            var plaintext = AesCtr.decrypt(ciphertext, password, bits);
            var blob = new Blob([plaintext], {type: 'application/octet-stream' });
            saveAs(blob, file.name.replace(/\.enc$/,''));
            document.querySelector('#progress').value = 0;
            const t2 = performance.now();
            const t = ((t2-t1)/1000).toFixed(3)+'s';
            document.querySelector('#decrypt-file-time').textContent = t;
            }           

        }
       
    });
</script>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda