Reprint: http://www.cnblogs.com/xqxacm/p/4886299.html
First, what is encoded decoding
Coding: The use of specific algorithms, the original content processing, generate the operation of the content, the formation of another form of data, can be based on the algorithm, and then restore back, this operation is called coding.
Decoding: Using the inverse operation of the algorithm used by the code, processing the encoded data, and restoring the original data, this operation is called decoding.
Second, what is the Base64 coding algorithm
Arbitrary byte array data can be generated by an algorithm that generates only the string data represented by (in the case of English, numeric, +,/) (64 characters).
Converts an arbitrary content into a visible string form.
Three, the origin of Base64 algorithm
Previously sent messages only support the delivery of visible characters. Thus, there is a need for a method to convert invisible characters to visible characters, resulting in the BASE64 encoding algorithm
Iv. Features of Base64 algorithm
1. The data is processed in the form of 3 bytes, and every three bytes are converted to 4 bytes after encoding.
That is, if a data has 6 bytes, it will be encoded with 6/3*4=8 bytes
2, when the length of the data can not meet a multiple of 3, the final data needs to fill the operation, that is, fill "=", where "=" is a fill character, do not understand as the 65th character
Eg: three bytes, converted to 4 bytes of the process:
As you can see, each of the three bytes of raw data is divided into a set of bits, divided into a byte per 6 bits, converted to form a new 4 bytes. These four bytes are mapped by the BASE64 encoding table, resulting in the final actual Base64 encoding.
If the original data cannot be made up to 3 bytes at the end, the fill is replaced with "=", which means there is no data
Five
BASE64 Coded Index Table
Vi. Base64 Usage Scenarios
1. The server passes binary data to the client in JSON
2, the client passes the parameter to the server, passes the binary content through the BASE64
Seven, the attention point
1, Base64 is a coding algorithm, not a cryptographic algorithm, just used to encode a byte array, form a string, and provide a decoding function
2, Base64.encodetostring (byte[] data,int flag);
The second parameter setting No_wrap means that the resulting string is wrapped.
Base64.encode (String str,int flag) Ibid.
BASE64 Coding algorithm