Use the MD5 value to add a file to the C # background

Source: Internet
Author: User

First, the concept and source of the MD5 value. MD5 's full name is Message-digest algorithm 5, developed by the MIT Computer Science Lab and RSA Data Security Inc in the early 90, with the development of MD2, MD3 and MD4.

Message-digest refers to a hash transformation of a byte string (Message), which transforms a byte string of any length into a long, large integer. Note that I used the word "byte string" instead of "strings" because the transformation is only related to the value of the byte, regardless of the character set or encoding. MD5 transforms any length of "byte string" into a large integer of 128bit, and it is an irreversible string transformation algorithm, in other words, even if you see the source program and algorithm description, you can not transform a MD5 value back to the original string, mathematically speaking, This is because the original string has an infinite number, which is somewhat like a mathematical function that does not have an inverse function.

The data after encrypting with MD5 is irreversible and can be used to encrypt the password in the database to ensure the security of the user.

  

        protected voidBtn_md5_click (Objectsender, EventArgs e) {            //Get encrypted content            stringContext = This.            Tbx_context.text; Clientscript.registerclientscriptblock (GetType (),"msg","<script>alert (' Encrypted result:"+ Getmd5data (Context) +"') </script>"); }         Public stringGetmd5data (stringp_date) {            //Create a MD5 objectMD5 MD5 =MD5.            Create (); //start Encryption,converts a string to a byte array, binary;            byte[] buffer =Encoding.UTF8.GetBytes (p_date); byte[] Md5buffer =md5.computehash (buffer);//each element in the byte array is ToString (); StringBuilder p_sb=NewStringBuilder ();  for(inti =0; i < md5buffer.length; i++) {P_SB. Append (Md5buffer[i]. ToString ("X2")); }            returnresult.        ToString (); }

  

Use the MD5 value to add a file to the C # background

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.