MD5 encryption implementation

We are here to share a super simple implementation of md5 encryption

as follows:

Namespace references

using System.Security.Cryptography;
using System.Text;

 

C # code

public static string MD5(string input)
{
  var output = string.Empty;
  var md5 = new MD5CryptoServiceProvider();

  var src = Encoding.UTF8.GetBytes(input);
  var des = md5.ComputeHash(src);

  for (int i = 0; i < des.Length; i++)
    output += des[i].ToString("X2");

  return output;
}

 

If you have questions, comments welcome

Guess you like

Origin www.cnblogs.com/ZbsCc/p/11589027.html