Friday, December 16, 2011

Encoding TIFF to base64 in C#?

It doesn't matter what kind of information you are converting to base 64, the input to such a conversion is simply a sequence of bytes. Take the bytes 3 at a time, converting those 24 bits into four 6-bit chunks, each 6-bit chunk will be a single character in base 64. The character are the upper and lower case letters, the ten digits, and the '+' and '/' characters (in that order). I wrote a base 64 decoder in C years ago, which was just a couple of pages of code, a C# base 64 encoder would likewise be a relatively minor effort. There is a slight detail for handling the case where the input is not an exact multiple of 6 bits, involving the '=' character.

0 comments:

Post a Comment