HOME / COMMUNITY Switch to knowledge base

MD5 Encryption API

Hi,
could you please help me with MD5 Hash encryption code base or any API if available. As I need to get that done before posting my request.

Thanks
Aashish

Hello @Aashish

What coding language are you using? MD5 is quite a common function, so there should be a way of achieving it

Thanks for quick response, I am using C#.Net.

Here’s an example from MSDN that you may find useful:

 public static string CreateMD5(string input)
    {
        // Use input string to calculate MD5 hash
        using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
        {
            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
            byte[] hashBytes = md5.ComputeHash(inputBytes);

            // Convert the byte array to hexadecimal string
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < hashBytes.Length; i++)
            {
                sb.Append(hashBytes[i].ToString("X2"));
            }
            return sb.ToString();
        }
    }

This topic was automatically closed after 7 days. New replies are no longer allowed.