本文介绍了.NET Standard 2.0和System.Security.Cryptography.ProtectedData.Protect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看
@

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

as we are looking to port a library from .NET Framework 4.7 to .NET Standard 2.0 to be used by .NET Core 2.0.I did a search and it only available in the full .NET Framework and .NET Core.

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

My question is, why is it not available in .NET Standard 2.0?

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

I would have thought that if it can be used in, for example, .NET Framework 4.7 and .NET Core 2.0 then it would also be part of .NET Standard 2.0

推荐答案

此API在 .NET Standard 2.0中不可用,但在 .NET中可用。标准2.0作为平台扩展,这意味着您必须添加一个NuGet软件包才能获得对其的支持。

This API is not available "in" .NET Standard 2.0, but it is available "for" .NET Standard 2.0 as a "Platform Extension" which means that there is a NuGet package you have to add to get support for it.

如果添加对<$的引用c $ c> System.Security.Cryptography.ProtectedData NuGet包,您可以开发一个使用这些API的.NET Standard库。

If you add a reference to the System.Security.Cryptography.ProtectedData NuGet package, you can develop a .NET Standard library that uses these APIs.

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

However, this support only works when run on Windows, since those APIs are described as

所以它不起作用在Windows以外的平台上。

so it won't work on platforms other than Windows. Depending on your needs, this may be just fine.

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

If you are looking to implement similar concepts cross-platform, I suggest looking into the ASP.NET Core Data Protection APIs which could also be used outside of the context of an ASP.NET Core app since it is made out of NuGet packages that provide cryptographic logic and key storage solutions (e.g. directory, windows certificate stores, Azure KeyVault).

这篇关于.NET Standard 2.0和System.Security.Cryptography.ProtectedData.Protect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 16:09