不使用Java.Runtime解密Java中的gpg [英] Decrypt gpg in Java without using Java.Runtime

查看:109
本文介绍了不使用Java.Runtime解密Java中的gpg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.gpg文件和RSA私钥.如何在不使用操作系统的情况下以编程方式对其进行解密?例如而不使用Runtime.getRuntime().exec("gpg -decrypt.....");

I have a .gpg file and a RSA private key. How can I programatically decrypt it without using operating system? e.g. without using something like Runtime.getRuntime().exec("gpg -decrypt.....");

我发现所有库都运行操作系统.像 GnuPG

Libraries I've found all run operating system. Like GnuPG or gnugpg-for-java.

推荐答案

Bouncy Castle 该库提供(除其他功能外)OpenPGP实现.软件包org.bouncycastle.openpgp.examples包含几个用法示例,其中一个示例演示如何使用公共/秘密密钥对加密/解密文件(您可以在项目的Github镜子).

The Bouncy Castle library provides (among other features) an OpenPGP implementation. The package org.bouncycastle.openpgp.examples contains several usage examples, one of them showing how to encrypt/decrypt a file using a public/secret key pair (you can have a look at the examples on GrepCode or on the project's Github mirror).

这篇关于不使用Java.Runtime解密Java中的gpg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆