Java Android中的视频解密问题

Java Android中的视频解密问题,java,android,encryption,aes,Java,Android,Encryption,Aes,我使用“AES”算法对视频进行解密,该算法以加密格式存储在外部Sd卡上。解密视频时,其解密率仅为47%,并停止。请给出解决方案 public void createDecryptedFile(File decryptedFileDir, File decryptedFile, File encryptedFile) { try { if (!decryptedFileDir.exists()) {

我使用“AES”算法对视频进行解密,该算法以加密格式存储在外部Sd卡上。解密视频时,其解密率仅为47%,并停止。请给出解决方案

public void createDecryptedFile(File decryptedFileDir, File decryptedFile,
                                File encryptedFile) {
    try {
        if (!decryptedFileDir.exists()) {
            decryptedFileDir.mkdirs();
        }
        Cipher decipher;
        decryptedFile.createNewFile();
        deleteFile = decryptedFile;
                        FileInputStream encryptedFileInputstream = new FileInputStream(
                encryptedFile);
        FileOutputStream decryptedFileOutputstream = new FileOutputStream(
                decryptedFile);

        decipher = Cipher.getInstance("AES");
        Key key = generateKey();
        decipher.init(Cipher.DECRYPT_MODE, key);

        CipherOutputStream cos = new CipherOutputStream(
                decryptedFileOutputstream, decipher);

        byte data[] = new byte[10000 * 1024];

        int count;
        try {

            while ((count = encryptedFileInputstream.read(data)) != -1  && !stopConversion) {
                Log.d("#########", "##########");

                total += count;
                Log.e("convert count", total + "");

                cos.write(data, 0, count);

                final long l = encryptedFile.length();

                runOnUiThread(new Runnable() {
                    public void run() {

                        // Show percentage 
                        loadingpercent.setText("" + (int) (total * 100 / l) + "%");
                    }
                });

                Log.d("$$$$$$$$",""+encryptedFileInputstream.read(data));

            }

请编辑您的问题以包含问题的答案。还要注意,在ECB模式下使用AES会使上述加密代码完全不安全。一般建议:始终使用完全限定的密码字符串<代码>Cipher.getInstance(“AES”)可能会产生不同的密码。它很可能会导致添加AES/ECB/PKCS5P“,但不必如此。如果它发生更改,您将失去不同JVM之间的兼容性。仅供参考:切勿使用。它是确定性的,因此在语义上不安全。您至少应该使用随机模式,如或。最好是对密文进行身份验证,这样就不可能进行类似的攻击。这可以通过诸如GCM或EAX之类的经过身份验证的模式来实现,也可以通过一个方案来实现。
Replace  :-


CipherInputStream cis = new CipherInputStream(encryptedFileInputstream, cipher);


            int count;
            try {


                int b;
                byte[] d = new byte[10000 * 2048];
                while ((b = cis.read(d)) != -1 && !stopConversion) {


                    total += b;

                    final long l = encryptedFile.length();


                    decryptedFileOutputstream.write(d, 0, b);


                    runOnUiThread(new Runnable() {
                        public void run() {
                            loadingpercent.setText("" + (int) (total * 100 / l) + "%");
                        }
                    });


                }