gpt4 book ai didi

asp.net-core - 我们在Asp.net 5 Core中使用了哪种加密算法

转载 作者:行者123 更新时间:2023-12-01 12:37:57 25 4
gpt4 key购买 nike

目前,当我将项目类型从 Asp.net 5.0 切换到 Asp.net 5.0 Core 时,几乎所有的加密算法都开始出现错误。这是因为它们都需要 System.Security.Cryptography 命名空间,这在 Core 5.0 中不可用。参见 some code examples here .知道我们可以在 Asp.net Core 5.0 中使用哪一个吗?

最佳答案

您应该使用 Microsoft.AspNet.Security.DataProtection 包。您可以使用的 2 个主要界面是:

https://github.com/aspnet/DataProtection/blob/dev/src/Microsoft.AspNet.Security.DataProtection/IDataProtectionProvider.cs

https://github.com/aspnet/DataProtection/blob/dev/src/Microsoft.AspNet.Security.DataProtection/IDataProtector.cs

在您的 Web 应用程序中,在 ConfigureServices 方法中,对服务集合调用 AddDataProtection 以使这些可用。

从那里,您应该能够通过依赖注入(inject)访问 IDataProtectionProvider。

关于asp.net-core - 我们在Asp.net 5 Core中使用了哪种加密算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27884517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com