This article illustrates the string MD5 code function implemented by C #. Share to everyone for your reference, specific as follows:
/*
test environment: WinXP SP3, Visual Studio 2008 SP1, Visual Studio SP1
Update: 2014-04-23/
public
string Calculatemd5hash (String input)
{
MD5 MD5 = System.Security.Cryptography.MD5.Create ();
byte[] inputbytes = System.Text.Encoding.UTF8.GetBytes (input);
Byte[] hash = Md5.computehash (inputbytes);
Step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder ();
for (int i = 0; I < hash. Length; i++)
{
sb. Append (Hash[i]. ToString ("X2"));
}
Return SB. ToString ();
} End Func
Read more about C # Interested readers can view the site topics: "C # string Operation Tips Summary", "C # Programming Thread usage Tips", "C # Operation Excel Skills Summary", "C # XML file Operation Tips Summary", "C # Common control usage Tutorial", " WinForm Control Usage Summary, C # tutorial on data structure and algorithms, C # array operation techniques Summary, and C # Introduction to object-oriented Programming
I hope this article will help you with C # programming.