Cómo descifrar un archivo en javascript que está cifrado por JAVA con AES

He cifrado el archivo JPG en Java con AES256, pero no tengo idea de descifrar el archivo JPG en javascript. Alguien tiene mejor idea? Estoy luchando con eso por 4 días.

 byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 String key = "1234567890123456789012345678901d";

 AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
 SecretKeySpec newKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
 cipher.init(mode, newKey, ivSpec);

 InputStream input = null;
 OutputStream output = null;

 try {
     input = new BufferedInputStream(new FileInputStream(new File("/home/java/test/aaa.JPG")));
     output = new BufferedOutputStream(new FileOutputStream(new File("/home/java/test/bbb.JPG")));
     byte[] buffer = new byte[1024];
     int read = -1;

     while((read = input.read(buffer)) != -1){
         output.write(cipher.update(buffer, 0, read));
     }

      output.write(cipher.doFinal());
 }
 finally {
     if(output != null){
         try {
             output.close();
         } catch(IOException ie){
             logger.info(ie.getMessage());
         }
     }
     if(input != null){
         try {
             input.close();
         } catch(IOException ie){
             logger.info(ie.getMessage());
         }
     }
 }

Aquí está el código que he probado hasta ahora. He usado CryptoJS y Decrypt no devuelve nada.

<!DOCTYPE html>
    <html>
    <head>

    <script type="text/javascript" src="./CryptoJS v3.1.2/rollups/aes.js"></script>
    <script type="text/javascript" src="jquery-3.2.1.min.js"></script>
    <meta charset=utf-8 />
    <title>JS Bin</title>

    <style>
      article, aside, figure, footer, header, hgroup, 
      menu, nav, section { display: block; }
    </style>
    </head>
    <body>
      <input type='file' onchange="readURL(this);" />
        <img id="blah" src="#" alt="your image" />
        <a class="download" href="">Download</a>

        <script>
        var a = $('.download');
        var key =  CryptoJS.enc.Hex.parse("1234567890123456789012345678901d");
        var iv =  CryptoJS.enc.Hex.parse("00000000000000000000000000000000");

        function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {


                    /////////
                    var decrypted = CryptoJS.AES.decrypt(e.target.result, key,
                    {
                            iv: iv,
                            mode: CryptoJS.mode.CBC,
                            padding: CryptoJS.pad.Pkcs7
                        }
                        ).toString(CryptoJS.enc.Latin1);


                    if(!/^data:/.test(decrypted)){
                        alert("Invalid pass phrase or file! Please try again.");
                        return false;
                    }

                    a.attr('href', decrypted);
                    a.attr('download', input.files[0].name.replace('.enc',''));             


            };

                //reader.readAsDataURL(input.files[0]);
                reader.readAsText(input.files[0]);
            }
        }


        </script>
    </body>
    </html>

Respuestas a la pregunta(1)

Su respuesta a la pregunta