C # MD5 encryption,

Source: Internet
Author: User

C # MD5 encryption,

1 using System. security. cryptography; 2 using System. text; 3 4 namespace Common 5 {6 public class Md5Helper 7 {8 public string GetMd5 (string txt) 9 {10 // create md5 object 11 MD5 md5 = MD5.Create (); 12 // convert the string into a byte array 13 byte [] bs = Encoding. UTF8.GetBytes (txt); 14 // encrypt 15 byte [] bs2 = md5.ComputeHash (bs); 16 // convert the byte array into a string 17 StringBuilder sb = new StringBuilder (); 18 for (int I = 0; I <bs2.Length; I ++) 19 {20 sb. append (bs2 [I]. toString ("X2"); // x lowercase X uppercase 21} 22 return sb. toString (); 23} 24} 25}

 

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.