When byte [] is converted to a base64 encoded string through convert. tobase64string, the data volume increases significantly. Why? The answer is in base64 encoding.
Base64 encoding uses 64 basic ASCII characters to re-encode the data. More specifically, the data to be encoded is split into byte arrays, with three bytes as a group. Sort the 24-bit data in order and divide the 24-bit data into four groups, that is, 6-bit data in each group. Then, add two zeros before the highest bits in each group to make up one byte. In this way, a 3-byte data is reencoded into 4 bytes. When the number of bytes of the data to be encoded is not an integer multiple of 3, that is to say, the last group is not three bytes long. At this time, the last group is filled with 1 to 2 bytes of 0. Add 1 to 2 "=" at the end after the final encoding ".
The base64 sequence table is:
Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 +/
According to the above encoding rules, after base64 encoding, the original three bytes will become four bytes, that is, the data volume is increased by 33.3%, plus the following Bytes:
Base64 encoding increases the data size by 33.4%