multicode is a simple tool to decode
protocol buffer data recursively. For example, it might be very useful when you store protocol buffers as a blob in your database. The protocol buffer file was encoded as base64 before and the database encodes blobs as hex values, thus we have three different encodings here. If you want to access the data from the database directly (e.g. for debugging purposes), you have to figure out how it was encoded exactly to do the correct decodings. This is the use case of the
decode command of this tool. It will use a brute-force approach to encode the data. As long as one encoder (base64, hex, proto) was successful, it will use the result and try to decode it again with the same decoders, as it might be just an intermediate result.
The proto decoding is very “lightweight” and does not use proto definition files, which might be an advantage when you don’t know which proto file was used for encoding. On the other hand, you won’t be able to see the proto fields, only the stored values. So, there is still room for improvements.
This tool is highly inspired by a program written by my colleague at work (which is more bound to the use cases of the company and uses internal proto files for decoding).
I’ve asked how to credit him, but the answer was, that he doesn’t care about any credits on this. So, I concluded he didn’t want to be associated with the code I wrote ;-)
» Read Me
multicode allows to input a (nested)
proto (protocol buffers) decoded sequence and will recursively try to encode it. This is helpful when you get encoded data but don’t exactly know how it was encoded or encoding might lead to cumbersome command concatenation.
First, let’s encode a string with hex and base64 encoding:
Decode using the pipe:
Decode in verbose mode:
Disable hex decoding: