有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用bouncy castle作为加密提供程序和GCM、cipherOutputStream时使用java。close()似乎没有抛出invalidCipherTextException

当使用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);
    }

}

我需要重写密码吗。doFinal()被调用了,还是我误解了什么


共 (0) 个答案