Java Base64 encoding exists \n\r condition

Source: Internet
Author: User

Today development encountered a situation: the BASE64 code generated on the server is not the same as my local generation (the difference of carriage return line), and later on the web search, the next test, the results are recorded as follows:

Online Search results: The Base64 line cannot exceed 76 characters, and a carriage return newline character is added. The carriage return line break (\ r \ n) "is only available in Windows, and Linux has only a newline (\ n), and the Mac has only a carriage return (\ r).

Your own test results:

Here I tested the two Base64 encoded classes provided by the JDK: Sun.misc.BASE64Encoder and Java.util.Base64.

Test environment: Windows 7

sun.misc.base64encoder:jdk1.6-jdk1.8

The generated base64 are included in the carriage return line.

java.util.base64:jdk1.7-jdk1.8 (jdk1.6 not)

The generated base64 does not contain carriage return line breaks.

Java Base64 encoding exists \n\r condition

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.