0
public byte[] DoEncrypt(string message, X509Certificate2 cryptCert)
{
byte[] signedBytes = new System.Text.UTF8Encoding().GetBytes(message);
EnvelopedCms encryptedMessage = new EnvelopedCms(new ContentInfo(signedBytes));
CmsRecipientCollection recipients = new CmsRecipientCollection();
CmsRecipient recipient = new CmsRecipient(cryptCert);
recipients.Add(recipient);
encryptedMessage.Encrypt(recipient);
return encryptedMessage.Encode();
}
當我的應用程序試圖對它進行加密拋出異常「encryptedMessage.RecipientInfos」扔類型的異常的消息「System.Security.Cryptography.CryptographicException '與文本「無效的加密消息類型」出現在行「encryptedMessage.Encrypt(收件人)」ASP.Net:「無效的加密消息類型」錯誤加密消息時
非常感謝Rasmus,但它沒有工作 – 2010-12-03 21:53:53