none
Managed vs. NonManaged(?) hashing algorythms [SHA512 vs. SHA512Managed]

    Question

  •  

    Hi!

     

    Could somebody please explain me what is the difference in practice between SHA512 and SHA512Managed? Or SHA384 and SHA384Managed?

     

    Thanks!

    Thursday, November 8, 2007 4:18 PM

Answers

  • Actually, this scenario is a little different.

     

    Yes, the SHA1Managed or [whatever-hash]Managed classes are all implemented in .NET and do not use unmanaged code from some other API (like Win32). That's true.

     

    However, the SHA1, MD5, and other non-Managed hash classes you see are abstract base classes for these algorithms. You cannot instantiate them, and they can not perform the actual work themselves. So, for example, all SHA1 concrete classes (assumed to implement the SHA1 algorithm) inherit from the SHA1 abstract base class.

     

    The reason for this is that you can code:

     

    SHA1 hashAlg = SHA1.Create();

    hashAlg.ComputeHash(someData);

     

    And underneath the covers, through config entries, you can control which concrete class actually gets created by default. In this case, it would be SHA1Managed, but an admin could switch the config entry out to some 3rd party SHA1 implementation, and your code would not care.

     

    Thursday, November 8, 2007 9:12 PM
  • Hi Ebence,

     

    They both do the same thing the only difference is the unmanaged version make calls the Windows Cryto Services API while I beleive the managed versions are fully managed, written in C# or something, but the algorthims are all ran in the .NET framework, not making any calls to Windows.

     

    here is a short statement from MSDN on SHA1Managed

     

    "This is a purely managed implementation of SHA1 that does not wrap CAPI" - CAPI being the crypo services of Windows.

     

    Thursday, November 8, 2007 4:42 PM

All replies

  • Hi Ebence,

     

    They both do the same thing the only difference is the unmanaged version make calls the Windows Cryto Services API while I beleive the managed versions are fully managed, written in C# or something, but the algorthims are all ran in the .NET framework, not making any calls to Windows.

     

    here is a short statement from MSDN on SHA1Managed

     

    "This is a purely managed implementation of SHA1 that does not wrap CAPI" - CAPI being the crypo services of Windows.

     

    Thursday, November 8, 2007 4:42 PM
  • Actually, this scenario is a little different.

     

    Yes, the SHA1Managed or [whatever-hash]Managed classes are all implemented in .NET and do not use unmanaged code from some other API (like Win32). That's true.

     

    However, the SHA1, MD5, and other non-Managed hash classes you see are abstract base classes for these algorithms. You cannot instantiate them, and they can not perform the actual work themselves. So, for example, all SHA1 concrete classes (assumed to implement the SHA1 algorithm) inherit from the SHA1 abstract base class.

     

    The reason for this is that you can code:

     

    SHA1 hashAlg = SHA1.Create();

    hashAlg.ComputeHash(someData);

     

    And underneath the covers, through config entries, you can control which concrete class actually gets created by default. In this case, it would be SHA1Managed, but an admin could switch the config entry out to some 3rd party SHA1 implementation, and your code would not care.

     

    Thursday, November 8, 2007 9:12 PM