【发布时间】:2021-11-25 10:34:59
【问题描述】:
在来自How can I SHA512 a string in C#? 的 .NET 6 代码中
var data = Encoding.UTF8.GetBytes("key");
byte[] hash;
using (SHA512 shaM = new SHA512Managed())
hash = shaM.ComputeHash(data);
抛出警告
Warning SYSLIB0021 'SHA512Managed' is obsolete:
'Derived cryptographic types are obsolete.
Use the Create method on the base type instead.'
Visual Studio 2022 不为此提供代码更改。 如何在 .NET 6 中用正确的代码替换此代码?
从 ASP.NET MVC 控制器调用代码。
【问题讨论】:
-
为什么不按照警告中的建议:
SHA512 shaM = SHA512.Create()和System.Security.Cryptography.SHA512? -
谢谢,它消除了警告。您可以将其写为答案
标签: asp.net-mvc cryptography sha sha512 .net-6.0