(1)
Using System.Security.Cryptography;
byte[] result = Encoding.Default.GetBytes (YPS);//tbpass a text box for entering a passwordMD5 MD5 =NewMD5CryptoServiceProvider (); byte[] Output =Md5.computehash (Result); stringstr = bitconverter.tostring (output). Replace ("-",""); if(str. length!= +) System.Diagnostics.Debug.WriteLine ("Start Debugging"); returnStr
(2)
Using System.Security.Cryptography;
stringCL =Yps; stringPWD =""; MD5 MD5= MD5. Create ();//instantiate a MD5 pair of images//after the encryption is an array of byte type, here should pay attention to the choice of coding utf8/unicode, etc. byte[] s =Md5.computehash (Encoding.UTF8.GetBytes (CL)); if(S.length! = -) System.Diagnostics.Debug.WriteLine ("Start Debugging"); //converts an array of byte types to a string by using a loop, which is a regular character formatting the resulting for(inti =0; i < s.length; i++) { //The resulting string is formatted using the hexadecimal type. The formatted character is a lowercase letter, and if uppercase (X) is used, the character after the format is uppercase charactersPWD = pwd + s[i]. ToString ("X"); } if(pwd. Length! = +) System.Diagnostics.Debug.WriteLine ("Start Debugging"); returnPwd
(3)
Using System.Web.Security;
" MD5 ");
The above three ways of MD5 encryption, the specific principle is not a cicada. Talk about the tiny difference.
(1) The MD5 value is the same as (3). (2) The MD5 value of (1) and (3) is slightly different because
PWD = pwd + s[i]. ToString ("X"), when the statement is converted to 16 binary, if the conversion value is one, such as 3, the other two methods at this time the value of the conversion is 03, resulting
The last Md5 value is less than or equal to 32 bits, resulting in Md5 values (2) and (1), (3) not necessarily equal
Therefore, if MD5 is encrypted, it is best to use the same method.
The differences of several kinds of MD5 encryption on the Internet