In a regular C# application which class to use for hashing: xxxManaged
or xxx
(i.e SHA1Managed
vs SHA1
) and why?
Managed classes are generally "safer" to use in .NET; they implement Framework-defined interfaces like IDisposable and ICryptoServiceProvider. However, they're a bit slower because of the managed component. You should use a managed class if you need to create and destroy these helpers at will, and/or if you need to implement interface-based design patterns.
Unmanaged classes are generally faster (because they are pre-compiled to machine code), but can be difficult to work with. Destroying an instance of an unmanaged class can be problematic and sometimes impossible. You should use these if there isn't a managed wrapper that will do the same thing (as you'll likely end up implementing your own wrapper for the unmanaged class to handle instantiation, interop and destruction), or if the usage is a one-off.