Ascii85 implementation in C#

Ascii85 is an encoding scheme that converts 4 bytes into 5 ASCII characters (in the range ! through u). As a result, it only has 25% encoding overhead compared to the 33% of Base64.

I recently needed to smuggle some binary data through HTTP headers without exceeding the message length limit; Ascii85 seemed like the best choice.

There were a couple of implementations available on the bathroom wall of code, but they had various problems that precluded their use:

  • No tests
  • Few comments
  • Unknown license
  • Violated .NET Framework Design Guidelines
  • NIH

So I wrote my own. The code is available on GitHub: Ascii85.cs, Ascii85Tests.cs

As with the other code on this blog, it’s released under a MIT-style license.

Posted by Bradley Grainger on February 18, 2012