相关疑难解决方法(0)

SHA256CryptoServiceProvider不符合FIPS标准?

我正在寻找符合FIPS标准的C#中的SHA256实现.事实证明SHA1CryptoServiceProvider工作.但是为什么SHA256CryptoServiceProvider会绊倒

{"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."}
Run Code Online (Sandbox Code Playgroud)

错误?似乎应该只是工作.

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()

c# encryption

5
推荐指数
1
解决办法
1492
查看次数

ASP.NET Core 3.1 SHA512 和 SHA256Managed 之间有什么区别

我目前正在使用SHA256Managedin ASP.NET Core 3.1,为了更安全,我想使用Hash512.

后缀Managed表明一个是托管代码,而另一个不是。

有人可以解释一下使用非托管与托管时需要考虑的任何问题吗?非托管是否需要任何特殊部署,例如在 Docker 容器中/或操作系统要求。

    private string Hash512(string str) {
        var message = Encoding.Unicode.GetBytes(str);
        var hash = SHA512.Create();

        var hashValue = hash.ComputeHash(message);
        return Encoding.Unicode.GetString(hashValue);
    }

    public string Hash256(string str)
    {
        var message = Encoding.Unicode.GetBytes(str);
        var hash = new SHA256Managed();

        var hashValue = hash.ComputeHash(message);
        return Encoding.Unicode.GetString(hashValue);
    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

5
推荐指数
1
解决办法
2210
查看次数

标签 统计

c# ×2

asp.net-core ×1

encryption ×1