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