A _c# tutorial of string MD5 code functions implemented by C #

Source: Internet
Author: User
Tags md5

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.

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.