MD5 hashes in C# – benchmark and speed optimization
For a current project I must generate a large number of MD5 hashes. I explicitly don’t want to discuss the meaning and security of MD5 hashes in this article, but rather concern myself with the question on how to generate MD5 hashes as fast as possible using C#.
The. NET Framework itself provides a class for creating MD5 hashes, which after the first attempts seemed a little slow to me. So I began to search for alternative classes and/or functions and came across a class of Syed Faraz Mahmood. His class is a manual implementation of the RFC 1321 (“The MD5 Message-Digest Algorithm”). The class can be downloaded for free on his blog.
The test environment
For the test I created six lists (List<int>) with many different numbers. Each with 1,000, 10,000, 50,000, 100,000, 1,000,000 and 10,000,000 elements.
All lists were run complete for both methods (MD5 .NET framework implementation & manual MD5 implementation) and […]