Java Implementation BASE64 codecAuthor: Chszs, reproduced in the note. Blog home:Http://blog.csdn.net/chszsBASE64 and other similar coding algorithms are often used to convert binary data into textual data, which is intended to simplify storage or transmission. In more detail, the BASE64 algorithm is primarily used to convert binary data into ASCII string formats
Java Implementation BASE64 codecChszs, reprint need to indicate. Blog home:Http://blog.csdn.net/chszsBASE64 and other similar coding algorithms are often used to convert binary data into textual data, which is intended to simplify storage or transmission. In more detail, the BASE64 algorithm is primarily used to convert binary data into ASCII string formats. The
Java Implementation BASE64 codecChszs, reprint need to indicate. Blog home:Http://blog.csdn.net/chszsBASE64 and other similar coding algorithms are often used to convert binary data into textual data, which is intended to simplify storage or transmission. In more detail, the BASE64 algorithm is primarily used to convert binary data into ASCII string formats. The
Java Implementation BASE64 codecChszs, reprint need to indicate. Blog home:Http://blog.csdn.net/chszsBASE64 and other similar coding algorithms are often used to convert binary data into textual data, which is intended to simplify storage or transmission. In more detail, the BASE64 algorithm is primarily used to convert binary data into ASCII string formats. The
Java uses Apache commons codec for MD5 encryption, BASE64 encryption and decryption, and executes system commands, commonsbase64
Before writing the code, let's first introduce the two packages we will use;
Commons-codec-1.10.jarTool packages used to process common encoding methods in the Commons project, such as DES, SHA1, MD5, Base64, URL, and Soundx.
Commons-ex
Java implements a conversion between a picture and a base64 stringPackagecom.zxc.testjava.ant;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.io.InputStream;ImportJava.io.OutputStream;ImportSun.misc.BASE64Decoder;ImportSun.misc.BASE64Encoder; Public classTestchangeimage { Public Static voidMain (string[] args) {String strimg=Getimagestr (); System.out.printl
.
WhenCodeIf the number is not an integer multiple of 3, the remainder of code/3 is 2 or 1. During conversion, if the result is less than six digits, 0 is used to fill in the corresponding position, and then two zeros are added before the six digits. After the empty output result is converted, "=" is used to fill the bits. For example, if the remaining result is two bytes of "sheets ":String "Zhang"11010101 HEX: D5 11000101 HEX: C5
00110101 00011100 00010100Decimal 53 decimal 34 decimal 20 pa
BASE64 encoding is a binary-to-character process that can be used to pass longer identity information in an HTTP environment.Base64 is a stringPom.xml Configuration Encrypt and decrypt code /*** Decryption * *@parampwd *@return * @see[Class, Class # method, Class # member]*/ Public Staticstring Decodestr (string pwd) {Base64 base64=NewBase64
Java Implementation BASE64 codecChszs, reprint need to indicate. Blog home:Http://blog.csdn.net/chszsBASE64 and other similar coding algorithms are often used to convert binary data into textual data, which is intended to simplify storage or transmission. In more detail, the BASE64 algorithm is primarily used to convert binary data into ASCII string formats. The
SHA checksum code). Call the digest method with the MessageDigest object to convert the number combination into a character array:1 String data = "1"; 2 3 MessageDigest MD = messagedigest.getinstance ("MD5"); 4 byte [] MD5 = md.digest (data.getbytes ()); 5 6 System.out.println (arrays.tostring (MD5));The array of bytes obtained is 128 bits , or 16 bytes. In other words, there are 16 elements in the character array after MD5, because the range of byte in
Base64 encoded after the formation of a more stupid way is to put this string on the Base64 decoding site, multiple decoding, can solve the problem, but a waste of time, consider a bit, you can use a simple Java program to solve the problem.The Java environment used is: jdk1.8.0_112. The development environment is: Ec
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.