Summary of the MD5 method in c #

Source: Internet
Author: User

/// <Summary>

/// 32-bit md5 /// </summary> /// <param name = "str"> </param> /// <returns> </returns> public static string GetBigMd5 (string str) {string cl = str; string pwd = ""; var md5 = MD5.Create ();
Byte [] s = md5.ComputeHash (Encoding. UTF8.GetBytes (cl ));
For (int I = 0; I <s. Length; I ++) {pwd = pwd + s [I]. ToString ("X2 ");}
Return pwd ;} /// <summary> /// 16-bit MD5 /// </summary> /// <param name = "str"> </param> /// <returns> </returns> public static string GetSmallMd5 (string str) {var md5 = new MD5CryptoServiceProvider (); string t2 = BitConverter. toString (md5.ComputeHash (UTF8Encoding. default. getBytes (str), 4, 8); t2 = t2.Replace ("-", ""); return t2 ;}
Private static string Encrypt (string strInput) {int I;
Int len = strInput. Length;
String strFont = strInput. Remove (len-1, 1); string strEnd = strInput. Remove (0, len-1 );
Var charFont = strFont. toCharArray (); for (I = 0; I <strFont. length; I ++) {int intFont = (int) charFont [I] + 3; charFont [I] = Convert. toChar (intFont );
} StrFont = ""; // let strFont null for (I = 0; I <charFont. length; I ++) {strFont + = charFont [I];} var strOutput = strEnd + strFont; return strOutput;
} Private static string Decrypt (string strInput) {int I;
String strFont = strInput. Remove (0, 1); string strEnd = strInput. Remove (1 );
Var charFont = strFont. toCharArray (); for (I = 0; I <strFont. length; I ++) {int intFont = (int) charFont [I]-3; charFont [I] = Convert. toChar (intFont );
} StrFont = ""; // let strFont null for (I = 0; I <charFont. length; I ++) {strFont + = charFont [I];} string strOutput = strFont + strEnd; return strOutput ;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.