简体   繁体   English

Bouncycastle 在标题中添加评论

[英]Bouncycastle add comments in header

In gpg you have the option to add comments to your signed file via the --comments option.gpg您可以选择通过--comments选项向签名文件添加注释。 Is there anything available for this on BouncyCastle icw Java ? BouncyCastle icw Java 上有什么可用的吗?

For example in gpg :例如在gpg

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

You should encode the output using the ArmoredOutputStream provided by bouncy castle:您应该使用充气城堡提供的 ArmoredOutputStream 对输出进行编码:

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

Result:结果:

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

There can only be one value for each header key, so you will have to extend ArmoredOutputStream to allow you to define multiple "Comment"每个标题键只能有一个值,因此您必须扩展 ArmoredOutputStream 以允许您定义多个“评论”

I hope that helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM