Random Project: Base64 Decoder
Nov 12 2014
In the past couple months I’ve become increasingly more interested and fascinated in GitHub. Now, most of this is likely due to the newbie CS student thinking “Woahhh, revision control and free project hosting” but GH is pretty remarkable. A project I’ve always been interested in doing was a blog where I write about whatever, much like the page you are reading right now. Eventually I found Jekyll, but before that I toyed around with the idea of hosting the raw text files on GitHub, decoding the text from base-64, and then pasting that to the template/page that I was actually using for the blog (likely on GitHub). Now this idea is actually really dumb and a lot more difficult than it needs to be, but that didn’t stop me from making the base-64 decoder in C++, because why not.
So, by reversing Wikipedia’s algorithm for base-64 encoding, I spent a little time and built the decoder. Basically, the algorithm is just:
- Convert each encoded character to ASCII values
- String together 6-bit strings of ASCII values
- Break string up into 8-bit strings
- Convert 8-bit strings back into ASCII values
- Convert to decoded character
Nothing groundbreaking but it was a fun little project. And who wouldn’t prefer doing little projects instead of sleeping? You can find the code here.