What is the difference between using MD5.Create and MD5CryptoServiceProvider?

System.Security.Cryptography.MD5.Create() is actually creating a MD5CryptoServiceProvider. That is why you see the same results.

Looking at the definition MD5 is the base class and it’s abstract. I’m guessing they added the public create function for ease of use.

public sealed class MD5CryptoServiceProvider : MD5 { }

public abstract class MD5 : HashAlgorithm { }

Take a look at the definitions.

MD5 Represents the abstract class from which all implementations of the MD5 hash algorithm inherit.

MD5CryptoServiceProvider Computes the MD5 hash value for the input data using the implementation provided by the cryptographic service provider (CSP). This class cannot be inherited.

Leave a Comment