Base64 encoding/decoding sample code


#1

Big thanks to Nick Stephens for donating this sample code to do the not-so-simple algorithm for base 64 encoding/decoding. The comments in the chart refer to this [URL=“http://en.wikipedia.org/wiki/Base64”]Wikipedia page on Base64.

Even if you’re not familiar with the term, I’m guessing you may have seen some base-64 encoded data at some point, perhaps in an email header, it looks like this:

TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=

Here’s the link to the chart you can import:
http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=4157

Note: this code is perfect for a subroutine, stay tuned more on converting your code into a subroutine.

-OptoMary