Fastest automotive Base64 encoder and decoder

 Base64 will probably not be used in the safety-critical parts of code, but if needed for some other segment, why not use the fastest and most secure and safe one?

Background story

We started IMProject back in 2021. It is in general Bootloader and Flasher ecosystem. Soon we figured out that we would like to use JSON for easy human readability of some identification and this is where we introduced Base64 into our project. 

Since we are writing our code following MISRA C:2012 we were searching for an automotive or avionic Base64 code but without luck. We figured out that we will need to do it by ourselves.
This is where Juraj jumped in and reused the algorithm of the fastest open-source Base64 encoder and decoder to rewrite it in C by MISRA C:2012 coding guidance.

What did we use?

There is a guy Gaspard Petit who tested probably all available base64 algorithms.
He went to the conclusion that the fastest base64 encoder is jounimalinen and polfosol decoder.
The original StackOverflow thread is in the link.


base64 encode decode fastest

Figure 1 - Table from Gaspard's tests

Fastest safe/secure Base64

Here is the link to our code. It is the part of our IMUtility repository where you can find also other automotive open-source code that we are slowly updating.
Base64 code is unit tested with Unity and tested to MISRA with Cppcheck.
License is BSD since it is inherited from the original Polfosol code.

I hope this will help your project.
Enjoy and BR,
Igor Mišić


Popular posts from this blog

AUTOSAR and CRC calculation

Flashing/debugging/running code at external memory in the memory-mapped mode

Debugging EK-TM4C123GXL with Visual Studio Code on Linux