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