base64
base64 test.txt -w0 > test-base64encoded.txt
base64 -d test-base64encoded.txt > test-output.txt
diff test.txt test-output.txt
-w0 allows for a very long base64 string, instead of each lines with fixed length
Padding
Base64 encoding increases file size by about 33%. The math works like this:
- Every 3 bytes (24 bits) of binary data are split into 4 groups of 6 bits.
- Each 6-bit group is represented as 1 ASCII character (1 byte).
- Thus, 3 raw bytes β 4 encoded bytes.
Thatβs 4/3 = 1.333β¦, or roughly a one-third increase.