Small white C # form series-08 talking about BASE64+MD5 encryption

Source: Internet
Author: User

What is Base64? How to say, this encryption is more commonly used, think of thunder, think of QQ Whirlwind and express. They are using this Base64 to encrypt the address, now online a lot of address resolver, the principle is anti-Base64.
The idea of BASE64 encoding is to re-encode the data using 64 basic ASCII characters. It splits the data that needs to be encoded into a byte array. A group of 3 bytes. The 24-bit data is sorted sequentially, and the 24 bits of data are divided into 4 groups, 6 bits per group. Then fill in a byte with two 0 in front of the highest bit of each group. This re-encodes a 3-byte set of data into 4 bytes. When the number of bytes of data to encode is not an integral multiple of 3, that is, the last group is less than 3 bytes at the time of grouping. At this point the last group is populated with 1 to 2 0 bytes. and add 1 to 2 "=" At the end after the last encoding is complete. See this example (example)
Inverse day is just a small white, small white, so advanced will not, just make simple it ~ directly with his default code library, not self-defined, if you want to make a custom look at the above example bar ~
We go to the point, alone a Base64 no meaning, send a say on the O, even if the MD5 series Encryption gadget expansion bar (then said the idea of expansion), first say Base64 how to encrypt and decrypt it:encryption: Convert.tobase64string (Basebuffer); //Give him a byte[] returns a string to decrypt: byte[] buffer = convert.frombase64string (Txtstring.text); //Give him a string, return a byte[] is not the language, so simple, in fact, the inverse of the day is to listen to friends to mention a bit, Java is now a base64+md5 combination, I think, anyway, Java has, brother also get a C # version of (grammatical or some difference "visual: Java MD5 not a one of the ToString    ("X2"); "). Here's a code: public void Getmd5base () {MD5 MD5 = MD5.        Create ();        string input = Txtstring.text; byte[] buffer = Encoding.UTF8.GetBytes (input);///String to byte[] arraybyte[] Newbuffer = md5.computehash (buffer, 0, buffer.        Length);        StringBuilder sb = new StringBuilder (); for (int i = 0; i < newbuffer.length; i++) {sb. Append (Newbuffer[i].    ToString ("X2")); } byte[] Basebuffer = Encoding.UTF8.GetBytes (sb.) ToString ()); Convert the MD5 32-bit ciphertext to byte[] Txtneed.text = convert.tobase64string (Basebuffer);//This should pay attention, do not turn in the Newbuffer, you decrypt the time will garbled (sometimes)}  decoding is simple: (This program encrypted ciphertext, in the decryption can only get MD5)  public void getmd5 () {    try     {        byte[] buffer =  Convert.frombase64string (Txtstring.text);                 txtneed.text = encoding.utf8.getstring (buffer);     }    catch { messagebox.show ("Please enter the correct Base64 code"); }}   Paste a source code and software bar: http://pan.baidu.com/s/1dDjD01z This issue recommended:reflector8.3   telerik JustdecompNext issue: SHA Series Encryption

Small white C # form series-08 talking about BASE64+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.