将java.security.PublicKey转换为充气城堡PGPPublicKey

问题描述 投票:3回答:1

我正在尝试使用弹性城堡加密字符串。我用来检索加密的公共密钥的库将其作为java.security.PublicKey对象返回。如何将其转换为PGPPublicKey对象,以便可以使用它来加密文件。

cryptography bouncycastle public-key-encryption pgp
1个回答
0
投票

您可以使用Bouncy Castle JcaPGPKeyConverter.getPGPPublicKey(int algorithm, PublicKey pubKey, Date time)转换密钥>

注:

传递的时间会影响密钥的keyID的值,因此您可能只希望对JCA密钥执行一次此操作,或者确保跟踪使用的时间。

请参见https://borelly.net/cb/docs/javaBC-1.4.8/pg/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.html

© www.soinside.com 2019 - 2024. All rights reserved.