我正在寻找符合FIPS标准的C#中的SHA256实现.事实证明SHA1CryptoServiceProvider工作.但是为什么SHA256CryptoServiceProvider会绊倒
Run Code Online (Sandbox Code Playgroud){"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."}
错误?似乎应该只是工作.
var sha = System.Security.Cryptography.SHA256CryptoServiceProvider.Create(); // not FIPS
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我使用的是.NET 4.5,但同样的事情发生在3.5和4.0中.我认为SHA256CryptoServiceProvider是符合FIPS标准的SHA256Managed替代品.SHA256Cng抛出相同的错误.
更新.我想我需要制作一个"新的SHA256CryptoServiceProvider"而不是使用Create()
正如更新中建议的原始海报,解决方案是实际创建 SHA256CryptoServiceProvider(或 512)的新实例。调用 Create 将不起作用:
var csp = new SHA512CryptoServiceProvider();
byte[] hashedBytes = csp.ComputeHash(......);
String hashedText = Convert.ToBase64String(hashedBytes);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1492 次 |
| 最近记录: |