[C#] Convert String to MD5 Hash

Swift Games Accounts
  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • ► You must register to download attachments!


Dec 5, 2012
Hi everyone. Well I thought people were kinda inactive atm so why not make a tutorial.

MD5 Hash

Ok so first we need a MD5CryptoServiceProvider .. To get this you need to "include" System.Security.Cryptography.

And then we can create it.

 [COLOR="#40E0D0"]MD5[/COLOR] md5Crypto = [COLOR="#008080"]new[/COLOR] [COLOR="#40E0D0"]MD5CryptoServiceProvider()[/COLOR];
Ok so time to create our Byte Arrays.
1 For our Normal Data (The string we wanna encrypt)
2 To store the hash

Byte[] NormalData, EncodedData;

Now lets set the Normal Data to the string we want, from bytes.

NormalData = ASCIIEncoding.Default.GetBytes("String");

Ok time to use our MD5CryptoServiceProvider..

Convert to MD5 Hash from our byte array (String):

EncodedData = md5Crypto.ComputeHash(NormalData);

Now u might think you can just outprint your Byte Array EncodedData to a string, You cant.

We need to use BitConverter

String Hash = BitConverter.ToString(EncodedData);


Thank you for watching my tutorial! Please reply :)

Last edited: