Which is faster, hex encoding or base64 encoding?

I want to send or save a huge binary file that needs to be encoded as text.

Which encoding method will be faster between encoding hex

and encoding base64

?

The data is about 40 MB or more, so performance matters.

+5


source to share


1 answer


The time it takes to code is not really an issue. Base64 is more complex, but encoding still won't be a big overhead. The real problem is the time it takes to transfer data over the network, which depends on the encoded size of the data.

  • Base64 expands the size of the data by one third compared to its binary form. So your 40MB file will be around 53MB.

  • Hex encoding will double the data size, so your 40MB file will be 80MB.



In short, Base64 wins.

+14


source







All Articles