Decoding invalid base64 with state machines

How many times did you try to decode a string and couldn’t because it was malformed? With state machines, we can dynamically decode malformed or incomplete strings. This talk will discuss how to implement such state machines and the problems you might encounter.

Abstract

How many times did you try to decode a string and couldn’t because it was malformed? With state machines, we can dynamically decode malformed or incomplete strings. This talk will discuss how to implement such state machines and the problems you might encounter. Applying university computer science to real projects is not always a straightforward process. This talk is an example of how to implement a finite state machine (FSM) from a paper design to a Go project. It all started with a bunch of malformed b64 strings that couldn’t be decoded by standard tools only because they had some invalid characters in the middle. After stripping a couple of them manually, it was time to solve this problem more definitively. Our use case was the decoding package of an open source suite to test web applications, Wapty (https://github.com/empijei/wapty). The decode package uses a finite state machine to parse strings and intelligently decode them. If an invalid sequence is encountered, the tool will replace it with a default character and then try to recover the decoding process. This is possible thanks to a FSM that peeks the next characters and, if they are valid, proceeds to decode them, otherwise ignoring them and moving on.

Video

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS