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 […]

How to retrieve default browsers path in C#

csharp_standard_browserBelow it will be about how to find the path to the default browser on Windows systems with help of C#. This makes sense, if you want to open a file using Process.Start () in the default browser.
Although one might assume that every Windows user has installed Internet Explorer and you should therefore simply use this to view files, but it does not necessarily increase the confidence of the user into the own application. So at least I, as a user, would be annoyed of my program, if this would always launch Internet Explorer instead of Firefox, which I have set as the default browser.
Now there are two ways to open the default browser in C #. Both have their advantages and disadvantages.
Option 1 – Process.Start() with an URL
The easiest […]

How to create video files in C# (from single images)

create videos in csharpToday there is again a bit of C# code. I’m writing about how you can create video files in C # from individual images or bitmaps. Using the AForge library, which I have used in the already in the C# webcam tutorial, this is going to be relatively simple.
For the following tutorial you need the AForge.Video.FFMPEG.dll library and its FFMPEG libraries. Both can be found by clicking the below link. On the downloadpage you have to select that .zip-file, which contains “(libs only)” in it’s filename.

AForge Libs Download

Now open your Visual Studio or an alternative program, that you want to use to write your program. (For the following tutorial I’m using Visual Studio.)
Create a project
Next you create a new project, I decided on a WinForms project, and wait until […]

Performance test: rotate images in C# – Bitmap.RotateFlip vs.Graphics-Object

During my search for a function to rotate images in C#, I came across the following post on rotate images with C #.
Besides the method presented in the article there were 2 other approaches presented in the comments and so the question was: which method is the fastest of them.
Since this also awakened my interest, I wrote a small test application which checks every of those functions for their performance.
After a few test runs, it became clear that the original solution from the above mentioned post was not suitable because it created a new bitmap every run, what eats tons of memory. Thus, the following function has been excluded from the tests.

public Bitmap rotateImage(Bitmap bitmap, float angle)
Bitmap returnBitmap = new Bitmap(bitmap.Width, bitmap.Height);
Graphics graphics = Graphics.FromImage(returnBitmap);
graphics.TranslateTransform((float)bitmap.Width / 2, (float)bitmap.Height / 2);

3 things you should know to speed up HttpWebRequest

HttpWebRequest LogoThose who work with the. NET framework and occasionally used the HttpWebRequest class, may have stumbled about the phenomenon that it seems to be quite slow in some cases. Especially if you use HttpWebRequest in combination with threading to get responses as quick as possible, the HttpWebRequest class quickly becomes a party pooper.
Initially you might assume that the problems rely on the Internet connection, but at least after a speed comparison with wget or curl, you should recognize that the “problem” must be at the. NET implementation.
No products found.In the following article I will focus on three points that can help you, to speed up the HttpWebRequests class.

1. Increase DefaultConnectionLimit
All instances of the HttpWebRequest class are using some properties of the ServicePointManager. One of these porperties of the ServicePointManager is the “DefaultConnectionLimit”. By default, this […]