A couple of weeks ago, I was trying to write web service examples in AL code for VS Code. Unfortunately, at that time, it was not possible to call the Base64 methods on the TempBLOB table. And because those functions on the TempBLOB table are using .Net, I figured it was going to take a while before we get Base64 support in AL code. So I decided to write Base64 encoding / decoding routines myself. Just as an excercise and at that moment I didn’t know if I would even succeed.
Well, it turned out that it was possible and I ended up with a Codeunit that was able to convert a string to Base64 and also back into a string. At that moment, I already read in a GitHub issue that Microsoft promised to make the Base64 functions on TempBLOB table available in the next update. So I decided to not publish the code and wait for the next update.
However, a new question came up about Base64. And apparently, people were still interested in having the code. Because they were talking about a file I figured the code should not only support strings, but also binary data. That was another challenge that I just wanted to pick up. So I did. The Codeunit is now supporting both text and binary data. For binary data the code works with InStream and OutStream variables. In that way there is no dependency on any table.
You can download the code from GitHub.