如何使用充气城堡加密时添加私钥 [英] How to add private key whileencrypting using bouncy castle
本文介绍了如何使用充气城堡加密时添加私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我是bouncy castle的新手,我试图在充气城堡中使用publickey加密文件,但加密后客户端无法解密文件,它显示错误私钥未找到,我跟踪签名生成器中的问题,请帮助我解决这个问题
我尝试过:
Hi all,
I am new to bouncy castle, and i tried to encrypt the file using publickey in bouncy castle, but after encrypting client can't decrypt file, it shows error privatekey not found, i traced the problem in signature generator,kindly help me with this problem
What I have tried:
Private Function InitSignatureGenerator(ByVal compressedOut As Stream) As PgpSignatureGenerator
Const IsCritical As Boolean = False
Const IsNested As Boolean = False
Dim tag As PublicKeyAlgorithmTag = m_encryptionKeys.SecretKey.PublicKey.Algorithm
Dim pgpSignatureGenerator As New PgpSignatureGenerator(tag, HashAlgorithmTag.Sha1)
pgpSignatureGenerator.InitSign(PgpSignature.BinaryDocument, m_encryptionKeys.PrivateKey)
For Each userId As String In m_encryptionKeys.SecretKey.PublicKey.GetUserIds()
Dim subPacketGenerator As New PgpSignatureSubpacketGenerator()
subPacketGenerator.SetSignerUserId(IsCritical, userId)
pgpSignatureGenerator.SetHashedSubpackets(subPacketGenerator.Generate())
Exit For
Next
pgpSignatureGenerator.GenerateOnePassVersion(IsNested).Encode(compressedOut)
Return pgpSignatureGenerator
End Function
推荐答案
以下文章可以帮助您:使用密码 - 基于Android的加密 [ ^ ]。
The following article may help you: Using Password-based Encryption on Android[^].
这篇关于如何使用充气城堡加密时添加私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文