本文整理匯總了C#中System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange方法的典型用法代碼示例。如果您正苦於以下問題:C# RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange方法的具體用法?C# RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange怎麽用?C# RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter
的用法示例。
在下文中一共展示了RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Receive
public void Receive(byte[] iv, byte[] encryptedSessionKey, byte[] encryptedMessage)
{
using (Aes aes = new AesCryptoServiceProvider())
{
aes.IV = iv;
// Decrypt the session key
RSAPKCS1KeyExchangeDeformatter keyDeformatter = new RSAPKCS1KeyExchangeDeformatter(rsaKey);
aes.Key = keyDeformatter.DecryptKeyExchange(encryptedSessionKey);
// Decrypt the message
using (MemoryStream plaintext = new MemoryStream())
using (CryptoStream cs = new CryptoStream(plaintext, aes.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(encryptedMessage, 0, encryptedMessage.Length);
cs.Close();
string message = Encoding.UTF8.GetString(plaintext.ToArray());
Console.WriteLine(message);
}
}
}
開發者ID:.NET開發者,項目名稱:System.Security.Cryptography,代碼行數:23,代碼來源:RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange