【问题标题】:Bouncycastle add comments in headerBouncycastle 在标题中添加评论
【发布时间】:2019-06-11 10:19:26
【问题描述】:

gpg 中,您可以选择通过--comments 选项将cmets 添加到您的签名文件中。在 BouncyCastle icw Java 上有什么可用的吗?

例如在gpg

gpg 
--batch              ^     
--digest-algo SHA256 ^     
--comment "<PGPRequest>Something</PGPRequest>"

【问题讨论】:

标签: java bouncycastle gnupg


【解决方案1】:

您应该使用 bouncy castle 提供的 ArmoredOutputStream 对输出进行编码:

    ArmoredOutputStream armoredOutputStream = new ArmoredOutputStream(output);
    armoredOutputStream.setHeader("Comment", "<PGPRequest>Something</PGPRequest>");

结果:

    -----BEGIN PGP MESSAGE-----
    Version: BCPG v1.64
    Comment: <PGPRequest>Something</PGPRequest>
    (...)

每个标题键只能有一个值,因此您必须扩展 ArmoredOutputStream 以允许您定义多个“评论”

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2020-01-21
    • 1970-01-01
    • 2018-12-23
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多