. NET Learning notes----2015-06-30 (MD5 encryption)

Source: Internet
Author: User
Tags array to string

    classProgram {Static voidMain (string[] args) {            //MD5 encryption is irreversible            strings = GetMD5 ("123");            Console.WriteLine (s);        Console.readkey (); }         Public Static stringGetMD5 (stringstr) {            //Create a MD5 objectMD5 MD5 =MD5.            Create (); //Start Encryption//need to convert a string into a byte array            byte[] buffer =Encoding.Default.GetBytes (str); //returns a well-encrypted byte array            byte[] Md5buffer =md5.computehash (buffer); //converts a byte array into a string//byte array to string, theoretically there are 3 ways//parses each element in a byte array into a string Encoding.Default.GetString (Md5buffer) According to the specified encoding format; //directly set the array to ToString (); Pass//each element in the byte array is ToString (); //return Encoding.Default.GetString (md5buffer);            stringSTR1 =NULL;  for(inti =0; i < md5buffer.length; i++) {str1+ = Md5buffer[i]. ToString ("X2"); }            returnstr1; }    }

. NET Learning notes----2015-06-30 (MD5 encryption)

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.