Search code examples
base64hexdump

Is base64 encoded file smaller than straight hexdump?


I was wondering if base64 provides any compression compared to straight hex-dump - that means turning every byte into two characters from range [a-f0-9].


Solution

  • Yes it does, because base64 has more characters to work with—64 instead of the 16 of hexdump. This is one of the purposes of base64.

    The Wikipedia article shows you the gain: If the binary data is n bytes, the base64 data is 4*ceil(n/3) bytes. (Compared to 2*n bytes for the hexdump.)

    So, instead of a 100% overhead, you get roughly a 33% overhead.