MD5 Hash Code Generator


This online tool generates MD5 hash codes for the given text. Read further to get the source code for the MD5 hash code generator in .NET, Java and PHP.


About MD5 Hash Generator Tool

This tool generates MD5 hash codes from the entered text.

Steps for using this tool:

  1. Enter or paste your text in the first text box and click Generate MD5 Hash Code button.
  2. The MD5 hash code for the entered text appears in the second box.

MD5 Cryptographic Hash Algorithm

MD5 Hash Code Generator Cryptography

MD5 Cryptography

MD5 is otherwise called as Message-Digest 5 Algorithm. This cryptographic algorithm is widely used to cross verify the data integrity. The MD5 algorithm computes and generates a hexadecimal number for text or binary value. This hexadecimal number is 36 digits long, i.e. 128 bit. The length of this hexadecimal hash code will be the same even if the input is 2 character string or 10,000 character text. For example, the MD5 hash code for is 8533baebba27067f05b73c760b332112.

MD5 hashing algorithm cannot be used for high security encryptions as there where flaws in the design which lead to hacking. So, nowadays high security applications uses SHA-1 and SHA-2 hashing algorithm. This does not mean we should not use MD5, instead we can use MD5 hashing for low profile usage like data validation, file validation, etc...

Uses of MD5 Hashing Algorithm

  1. The best example is to verify the file downloaded from internet. While downloading a file from internet there are possibility of the file corrupted due to internet disconnections ot the file got tampered with. To verify the authenticity of the downloaded file, the MD5 hash code of the downloaded file can be verified with the MD5 hash code generated from the source file. Thus any tampering or data loss can be identified.
  2. Generating MD5 hash code for strings and texts will be useful for password encryption, validating the authenticity of email content, etc..

Programming MD5 Hash Generator

Major programming languages has inbuilt MD5 classes to generate and verify MD5 hash codes.


.Net has System.Security.Cryptography.MD5 abstract class. This class has ComputeHash(Byte[]), ComputeHash(Stream) and ComputeHash(Byte[], Int32, Int32) methods which can be used to generate MD5 hash codes.

Below is a simple .Net C# class method which takes a string as input and returns MD5 hash code.

public static string Generate(string strInput)
    MD5 md5 = new MD5CryptoServiceProvider();

        //provide the string in byte format to the ComputeHash method.
    //This method returns the MD5 hash code in byte array
    byte[] arrHash = md5.ComputeHash(Encoding.UTF8.GetBytes(strInput));

        // use a Stringbuilder to append the bytes from the array to create a hash code string.
    StringBuilder sbHash = new StringBuilder();

        // Loop through byte array of the hashed code and format each byte as a hexadecimal code.
    for (int i = 0; i < arrHash.Length; i++)

        // Return the hexadecimal MD5 hash code string.
    return sbHash.ToString();


In Java you can use the MessageDigest abstract class to generate the MD5 hash code for a string

Below is a simple java class method which takes a string as input and returns MD5 hash code.

import java.math.BigInteger;
public class MD5 {
    public static String GenerateHash(String input) {
        MessageDigest objMD = MessageDigest.getInstance("MD5");
        byte[] bytMD = mobjMDd.digest(input.getBytes());
        BigInteger intNumber = new BigInteger(1, bytMD);
        String strHashCode = intNumber.toString(16);
        // pad with 0 if the hexa digits are less then 32.
        while (strHashCode.length() < 32) {
            strHashCode = "0" + strHashCode;
        return strHashCode;


PHP has MD5() method to calculate MD5 hash code.

$str = "";
echo md5($str);


Page Last Modified On: Jul 23, 2021

Disclaimer: We took every effort to provide higher level of accuracy in the calculators, converters and tools we have added to Tools section. But, we cannot give any guarantee or can be held responsible for any errors, defects, faults or mistakes in any of the calculators, converters or tools. Please see detailed terms of use and liability disclaimer in Terms of Use Page.

Follow Us