c# - Hash Algorithm 的 "Create"方法的文档是否有缺陷?

标签 c# .net security hash cryptography

MSDN有一个表,其中包含对该方法有效的值。但是 SHA1CryptoServiceProviderSHA1Cng 成功了,即使它们不在列表中也是如此。

HashAlgorithm.Create("System.Security.Cryptography.SHA1Cng");

文档不完整,还是我误解了它们?

最佳答案

我不相信你有任何误解。该文档似乎不仅不完整,而且不正确。

不仅有其他值返回哈希算法的实例,而且它使用的查找表也会导致它抛出异常而不是返回 null

例如,下面的每一个都会抛出一个InvalidCastException,但是文档明确指出它应该返回null

System.Security.Cryptography.HashAlgorithm.Create("1.2.840.113549.1.9.3");
System.Security.Cryptography.HashAlgorithm.Create("Triple DES");
System.Security.Cryptography.HashAlgorithm.Create("X509Chain");

关于c# - Hash Algorithm 的 "Create"方法的文档是否有缺陷?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31816785/

相关文章:

c# - 年、月和日中 2 天之间的差异

c# - 如何从另一个 View 模型实例化和显示一个 ViewModel

java - java中的细粒度身份验证

azure - Azure Sphere 如何在嵌入其他 MCU 的混合系统中提供安全性?

c# - 如何使用 EPPlus 隐藏 Excel 电子表格中的大量列?

c# - SQL Server 2005 SQL 身份验证连接字符串

c# - C# 线程切换

c# - MS 图表 : Getting the real InnerPlotPosition?

c# - 不同语言的注册表值

c# - 安全保存银行账户数据