Chinese garbled characters in base64 Encryption

Source: Internet
Author: User

Base64 encodes binary data into four-byte readable characters per three bytes. The encoded characters are about 136.1% characters in length. Character range is A-Z A-Z 0-9 \ +. However, the encoded string is not suitable for URL transmission. The garbled characters after Chinese encryption are also caused by this reason: When the string is transmitted in the URL, the plus sign will be replaced with a space; a newline "\ n" is added for every 76 characters, which will be lost.

For example:

Haha ....

Haha ....

Haha ....

Will be encoded:

Uf65/rn + uf65/rn + oaoho6gjdqoncrn + uf65/rn + uf65/qgjoaohow0kdqq5/rn + uf65/rn + uf6h \ no6gjoam =

When it is transmitted in the URL, it will become:

Uf65/RN uf65/RN oaoho6gjdqoncrn uf65/RN uf65/qgjoaohow0kdqq5/RN uf65/RN uf6h
O6gjoam =

There will be problems with parsing.

Therefore, the following processing is required during transmission and decryption:

1. Remove \ n

2. Replace the space with +

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.