C # Basic _ MD5,
MD5 Encryption
1. Create Md5
2. Start encryption and convert characters into byte arrays.
3. Return an encrypted byte array
4. parse each element in the byte array into a string according to the specified encoding format
1 static void Main (string [] args) 2 {3 4 string s = GetMD5 ("123"); 5 6 Console. writeLine (s); 7 Console. readKey (); 8 9 10} 11 12 13 14 public static string GetMD5 (string str) 15 {16 // create MD5 object 17 MD5 md5 = MD5.Create (); 18 // start encryption 19 // convert the character to a byte array 20 byte [] buffer = Encoding. getEncoding ("GBK "). getBytes (str); 21 // returns an encrypted byte array 22 byte [] MD5Buffer = md5.ComputeHash (buffer ); 23 24 // convert the byte array to a string 25 // byte array --- string 26 // parse each element of the byte array into a string in the specified encoding format 27 // directly convert the Array toString (); 28 // ToString () 29 // return Encoding for each element in the byte array. getEncoding ("GBK "). getString (MD5Buffer); 30 31 // 189 273 345 I love you 32 // 189 273 34533 string strNew = ""; 34 for (int I = 0; I <MD5Buffer. length; I ++) 35 {36 strNew + = MD5Buffer [I]. toString ("x2"); 37} 38 return strNew; 39}