.net-core - .NET Standard 2.0和System.Security.Cryptography.ProtectedData.Protect

标签 .net-core .net-standard-2.0

我在看System.Security.Cryptography.ProtectedData.Protect
@ https://docs.microsoft.com/en-gb/dotnet/api/

因为我们希望将库从.NET Framework 4.7移植到.NET Standard 2.0,以供.NET Core 2.0使用。
我进行了搜索,并且仅在完整的.NET Framework和.NET Core中可用。

我的问题是,为什么它在.NET Standard 2.0中不可用?

我本以为,如果可以在.NET Framework 4.7和.NET Core 2.0中使用它,那么它也将成为.NET Standard 2.0的一部分。

最佳答案

该API在“.NET Standard 2.0”中不可用,但在“.NET Standard 2.0”中作为“Platform Extension”提供,这意味着您必须添加一个NuGet软件包才能获得对它的支持。

如果添加对System.Security.Cryptography.ProtectedData NuGet包的引用,则可以开发使用这些API的.NET Standard库。

但是,此支持仅在Windows上运行时有效,因为这些API被描述为

Provides access to Windows Data Protection Api.



因此它不适用于Windows以外的平台。根据您的需求,这可能很好。

如果您希望跨平台实现类似的概念,我建议您研究ASP.NET Core Data Protection APIs,它也可以在ASP.NET Core应用程序的上下文之外使用,因为它是由提供加密逻辑和 key 存储解决方案的NuGet包制成的。 (例如,目录,Windows证书存储区,Azure KeyVault)。

关于.net-core - .NET Standard 2.0和System.Security.Cryptography.ProtectedData.Protect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48208262/

相关文章:

c# - 构建 : error MSB4062 Microsoft. Build.Tasks.ResolveComReference 时出现 .NET Core 错误

.net - 软件包安装在 docker 内,但实际命令提供异常

c# - Xamarin 和 .NET Standard 2 库问题

c# - 将 IHttpClientFactory 传递给 .NET Standard 类库

.net-core - .Net Core 自动生成字符串主键

c# - KeyDerivation.Pbkdf2 和 Rfc2898DeriveBytes 有什么区别?

.net - 无法安装 .NET Standard 2.0

asp.net - 无法将 IdentityServer4 添加到 ASP.NET Framework 4.7.2 API OWIN

.net-core - 包含 dotnet core 应用程序的运行时文件夹