我一直有這個問題。該平臺不支持Diffie-Hellman加密算法
此平臺不支持指定的加密算法。
異常詳細信息:System.PlatformNotSupportedException:此平臺不支持指定的加密算法。
以下是代碼。此代碼在裝有3.5框架的Windows XP Pro SP3和Windows 2003 Server上失敗。
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Web"%>
<%@ Import Namespace="System.Security.Cryptography"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<%
//http://blogs.msdn.com/b/shawnfa/archive/2007/01/22/elliptic-curve-diffie-hellman.aspx
//http://msdn.microsoft.com/en-us/library/cc488021.aspx is about 200-millisecond wait.
ECDiffieHellmanCng alice = new ECDiffieHellmanCng();
alice.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
alice.HashAlgorithm = CngAlgorithm.Sha256;
ECDiffieHellmanCng bob = new ECDiffieHellmanCng();
bob.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
bob.HashAlgorithm = CngAlgorithm.Sha256;
byte[] bobKey = bob.DeriveKeyMaterial(alice.PublicKey);
byte[] aliceKey = alice.DeriveKeyMaterial(bob.PublicKey);
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
aes.Key = aliceKey;
%>
</body>
</html>
http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.ecdiffiehellmancng.aspx 該文檔說 Windows 7,Windows Vista SP1或更高版本,Windows XP SP3,Windows Server 2008(服務器核心角色不支持),Windows Server 2008 R2(不支持服務器核心角色) .NET Framework不支持所有平臺的所有版本。有關受支持版本的列表,請參閱.NET Framework系統要求。 受以下版本支持:4,3.5 – NanoHead 2010-07-07 21:36:28