我一直有这个问题。
The specified cryptographic algorithm is not supported on this platform.
Exception Details: System.PlatformNotSupportedException: The specified cryptographic algorithm is not supported on this platform.
下面是代码。此代码在安装了 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>
最佳答案
MSDN表示该类在以下操作系统上受支持:
- Windows 7
- Windows Vista SP1 或更高版本
- Windows XP SP3
- window 服务器 2008 (不支持服务器核心角色)
- Windows Server 2008 R2(服务器核心 不支持角色)
关于c# - 此平台不支持 Diffie-Hellman 加密算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3198954/