SHA2 (SHA256, SHA512) algorithms are better than MD5 for many reasons.
- They are more resistant to collisions, which is very important for large files. Although MD5 may detect changes to the contents of a file, it is more likely that two large files may have the same MD5.
- They are BASED for calculation. It may seem strange, but the SHA algorithm is accelerated both on chipsets and on OS implementations. Algorithms themselves are easier to parallelize. As a result, native implementations of SHA or SHA2 algorithms in Vista + are much faster than the equivalent MD5 algorithm.
- They use a larger block size, which means that they can work with large file blocks at a time. I / O time can add up when processing large files.
Native implementations in .NET: SHA256Cng , SHA384Cng, and SHA512Cng. Instead of creating them explicitly, you can define them as the default algorithm that will be used when hashing with <cryptoClass> in your configuration file.
After that, you can simply write HashAlgorithm.Create() or SHA256256.Create() to create your own instance.
Panagiotis kanavos
source share