使用哪一个:托管与非托管散列算法 [英] Which one to use: Managed vs. NonManaged hashing algorithms
问题描述
在一个常规的C#应用程序中使用的哈希,哪一个类: xxxManaged
或 XXX
(即 SHA1Managed
VS SHA1
),为什么?
In a regular C# application which class to use for hashing: xxxManaged
or xxx
(i.e SHA1Managed
vs SHA1
) and why?
推荐答案
在非托管哈希其端 ***压缩天然气
,即 SHA256Cng ,也会有平台的限制。他们比管理方案快了不少,但将在Windows XP上运行时失败,例如。如果你知道你的程序将始终在Windows 7,Vista SP1的,或2008上运行,但是,他们通常会执行颇有几分比管理的版本更好,甚至与本地互操作的开销。
The Non-managed hashes which end in ***Cng
, ie SHA256Cng, will also have platform restrictions. They are quite a bit faster than the managed alternatives, but will fail at runtime on Windows XP, for example. If you know your program will always be run on Windows 7, Vista SP1, or 2008, however, they will generally perform quite a bit better than the managed versions, even with the native interop overhead.
如果你正在写一个通用方案, ***托管
类会更容易的工作,因为他们永远是可行的。
If you're writing a general purpose program, the ***Managed
classes will be easier to work with, as they will always work.
这篇关于使用哪一个:托管与非托管散列算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!