Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当使用bouncy castle作为加密提供程序和GCM时,cipherOutputStream.close()不';t似乎不会抛出invalidCipherTextException_Java_Bouncycastle - Fatal编程技术网

Java 当使用bouncy castle作为加密提供程序和GCM时,cipherOutputStream.close()不';t似乎不会抛出invalidCipherTextException

Java 当使用bouncy castle作为加密提供程序和GCM时,cipherOutputStream.close()不';t似乎不会抛出invalidCipherTextException,java,bouncycastle,Java,Bouncycastle,当使用Bouncy Castle作为提供程序和GCM时,如果我故意修改密码文本,则应引发invalidCipherTextException,如果我在cipherOutputStream.close()的调试模式下单步执行,则可以看到invalidCipherTextException,但无法捕获此异常 BufferedInputStream is = new BufferedInputStream(new FileInputStream(user.encrypte

当使用Bouncy Castle作为提供程序和GCM时,如果我故意修改密码文本,则应引发invalidCipherTextException,如果我在cipherOutputStream.close()的调试模式下单步执行,则可以看到invalidCipherTextException,但无法捕获此异常

               BufferedInputStream is = new BufferedInputStream(new FileInputStream(user.encryptedDirectory.containedFiles.get(counter)));
                CipherOutputStream os = new CipherOutputStream(new FileOutputStream(user.unencryptedDirectory.location.toAbsolutePath() +  "\\"+ user.encryptedDirectory.containedFiles.get(counter).getName() + ""), cipher);
                copy(is,os);
                is.close();
                os.close();


    private static void copy(InputStream is, OutputStream os) throws IOException {
    int i;
    byte[] b = new byte[1024];
    while((i=is.read(b))!=-1) {
        os.write(b, 0, i);
    }

}
我是否需要重写以调用cipher.doFinal(),还是我误解了什么