使用充气城堡 lib

问题描述

我正在尝试使用 bouncycastle 生成 BcPGP 密钥对,但我找不到任何有关如何在不使用弃用材料的情况下执行此操作的文档。我正在使用以下函数在返回语句 unkNown key class 处抛出 PGP 异常。

这是异常的堆栈跟踪

org.bouncycastle.openpgp.PGPException: unkNown key class
    at org.bouncycastle.openpgp.operator.bc.BcPGPKeyConverter.getPGPPrivateKey(UnkNown Source)
    at org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair.getPrivateKey(UnkNown Source)
    at org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair.<init>(UnkNown Source)
    at Client.Encryptor.generateRsaKeys(Encryptor.java:31)
    at Client.Encryptor.<init>(Encryptor.java:66)
    at Client.Client.run(Client.java:70)
    at Client.Main.main(Main.java:20)

代码

    private BcPGPKeyPair generateRsaKeys () throws PGPException {
        RSAKeyPairGenerator gen = new RSAKeyPairGenerator();

        gen.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537),new SecureRandom(),2048,5));
        asymmetricCipherKeyPair keyPair = gen.generateKeyPair();
        return new BcPGPKeyPair(PGPEncryptedData.AES_256,keyPair,new Date());
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...