Detailed introduction and simple example of Java base64encoder
Detailed explanation of Java base64encoder
Base64 is one of the most common encoding methods for transmitting 8bit byte code on the network. When sending e-mail, the user name and password authenticated by the server need to be Base64 encoded, and the attachments also need to be Base64 encoded.
Base64 requires converting every three 8bit bytes into four 6bit bytes (3 * 8 = 4 * 6 = 24), and then adding two higher bits of 0 to 6bit to form four 8bit bytes, that is, the converted string will theoretically be 1 / 3 longer than the original.
The last three bytes of the original text are supplemented by 0. During conversion, Base64 coding is replaced by the = sign. This is why some Base64 codes end with one or two equal signs, but there are only two equal signs at most.
Java code implementation:
Base64encoder and base64decoder are both internal methods of Sun company and have not been disclosed in the Java API, so using these methods is unsafe and may be removed from them at any time in the future. Therefore, alternative objects and methods should be used accordingly
Solution to base64encoder not found in Eclipse: set the eclipse Import% Java as follows_ Just use the rt.jar package in the home% \ JRE \ lib directory, project - > properties, select the Java build path setting item, select the libraries tab, add external jars, and add% Java_ Home% \ JRE \ lib \ rt.jar can be used!
Base64. java
Thank you for reading, hope to help you, thank you for your support to this site!