Which one to use: Managed vs. NonManaged hashing algorithms

后端 未结 6 1807
离开以前
离开以前 2021-01-01 14:03

In a regular C# application which class to use for hashing: xxxManaged or xxx (i.e SHA1Managed vs SHA1) and why?

6条回答
  •  温柔的废话
    2021-01-01 14:28

    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.

提交回复
热议问题