JAVA中的GPG解密
通过上述代码动态传递值时,不会生成输出文件JAVA中的GPG解密,java,gnupg,Java,Gnupg,通过上述代码动态传递值时,不会生成输出文件 我正在windows中运行此程序。为什么您要使用外部程序而不是bouncycastle或其他加密库?我对密码学一无所知,只是想让我的代码尽可能简单,您能否共享bouncycastle代码示例的链接。。。如果可以,我会尝试加密库 public static void doDecrypt(String source,String dest ){ Runtime rt = Runtime.getRuntime(); GPGDecrypt r
我正在windows中运行此程序。为什么您要使用外部程序而不是bouncycastle或其他加密库?我对密码学一无所知,只是想让我的代码尽可能简单,您能否共享bouncycastle代码示例的链接。。。如果可以,我会尝试加密库
public static void doDecrypt(String source,String dest ){
Runtime rt = Runtime.getRuntime();
GPGDecrypt rte = new GPGDecrypt();
Process proc;
StreamWrapper error, output = null ;
try {
proc = rt.exec("gpg --output "+dstfile +" --batch --passphrase "+ResourcePropertyManager.get("Passphrase")+ " --decrypt "+srcfile);
System.out.println("After Passing");
error = rte.getStreamWrapper(proc.getErrorStream(), "ERROR");
output = rte.getStreamWrapper(proc.getInputStream(), "OUTPUT");
int exitVal = 0;
error.start();
output.start();
error.join(3000);
output.join(3000);
exitVal = proc.waitFor();
System.out.println("Output: " + output.message + "\nError: "+ error.message);
} catch (IOException e) {
System.out.println("IO "+e.getMessage());
e.printStackTrace();
} catch (InterruptedException e) {
System.out.println("IEX"+e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
rt = null;
rte = null;
proc = null;
error = null;
output = null;
}
}