为什么要使用 System.Security.Cryptography 哈希的非托管实现?

发布于 2024-10-09 15:54:54 字数 464 浏览 0 评论 0原文

例如,Microsoft 提供 SHA1Managed 和 SHA1CryptoServiceProvider(非托管)作为 SHA1 的实现。

使用非托管实现而不是托管实现的优点和缺点是什么(如果有)?

感谢您的帮助!

更新:

SLAks、Chochos 和 fejesjoco 的答案非常有用,但我选择了 SLAks,因为他要求我这么做。 :-)

作为摘要,请选择:

  • 托管 - 如果您不确定您的平台是否支持非托管实施(即,如果您要部署到 Azure)。
  • 非托管 - 如果您需要遵守联邦信息处理标准 (FIPS) 和/或您希望利用硬加速。

For example, Microsoft provides both SHA1Managed and SHA1CryptoServiceProvider (Unmanaged) as implementations of SHA1.

What, if any, are the advantages and disadvantages of using the unmanaged implementation instead of the managed implementation?

Thanks for any help!

Update:

The answers from SLaks, Chochos, and fejesjoco were very useful, but I chose SLaks because he asked me to. :-)

As a summary, choose:

  • Managed - If you are unsure whether your platform supports the unmanaged implementations (i.e. if you're deploying to Azure).
  • Unmanaged - If you need to comply with the Federal Information Processing Standard (FIPS) and/or you wish to take advange of hardward acceleration.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不甘平庸 2024-10-16 15:54:54

CSP 实施经过 FIPS 认证。

如果在本地安全策略中启用了 FIPS,*托管类将引发异常。

The CSP implementation is FIPS-certified.

If FIPS is enabled in Local Security Policy, the *Managed classes will throw an exception.

回忆凄美了谁 2024-10-16 15:54:54

如果您有硬件加密加速器,则需要使用非托管实现来访问它,因为托管实现不会使用它。

If you have a hardware cryptographic accelerator, you'll need to use an unmanaged implementation to access it, since the managed implementatios won't use it.

仙女 2024-10-16 15:54:54

我假设托管实现保证是平台独立的。

I'd assume the managed implementation is guaranteed to be platform independent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文