3 ms·
The site is down, but the answer is 33%. (four output bytes for every three input bytes). It could be slightly less if you want to remove the padding and calcu
by leetbulb 8y ago
The site is down, but the answer is 33%. (four output bytes for every three input bytes).
It could be slightly less if you want to remove the padding and calculate what the padding should be on the decoding side: base64string.length % 4.
Edit: If no entropy is added, it's still ~33%. C'mon :P
- BeeOnRope 8y agoWhen it's up, you'll see the article goes a bit beyond a literal reading of the title: the topic is the overhead of base64 under the assumption that the output ends up compressed with something like gzip.
- leetbulb 8y agoFigured as much. Interested to see the results. My assumption is that it doesn't change much. However, I suppose that depends on the compression algorithm.
- BeeOnRope 8y agoIn principle a good byte-wise entropy coder should recover nearly 100% of the base-64 "inflation" since no entropy is added. In practice gzip doesn't get all of it since it is an imperfect entropy coder for several reasons.
- hermitdev 8y agoYou are correct, but gzip is a generally happy medium of cost to encode/decode and encoded size when transmitting over a fast network. For a 10 Mbps or greater link, if you use something like bzip2 or 7z, you'll likely spend more time encoding than transmitting a payload. This is from my personal experience utilizing gzip and bzip2 via Boost Iostreams to compress network payloads over a 1Gbps link. End to end latency was far superior with gzip than bzip2, despite bzip2 having a smaller transmission size.
- BeeOnRope 8y agogzip is only a happy medium if your other candidates are 7z (LZMA) or bzip2, which are both stronger but slower compressors. bzip2 is essentially obsolete (off the pareto frontier), and LZMA is good but slow so will only be best if your transmission speed is low. Near the space/time tradeoff point that gzip lives, however, it is thoroughly outclassed by more modern compressors such as zstd or brotli with the appropriate settings.
- tedunangst 8y agoFrom personal experimentation, a gzipped base64 jpeg is close to the same size as the jpeg. So if you want to efficiently store some emails, it doesn't really matter whether you decode and store attachments separately or just compress the raw text. (Although decoding and separating allows deduping.)