For debugging I often find it useful to visualize byte arrays (for example hashed passwords) as BASE64 strings.
public override string ToString()
{
return Convert.ToBase64String(this.Hash);
}
But for large hashes (say more than 32 bytes) BASE64 encoding produces a string that is quite long. This makes it hard to compare them quickly by just looking at them.
BASE64 only uses 64 printable characters. I wonder if there are other encoding techniques that use more than 64 characters (but still only printable characters) to reduce the length needed to represent 32 bytes. It seems to me that we can greatly improve since on my keyboard I already see 94 easily distinguishable printable keys.
Of course, making byte arrays easily comparable by humans is not what BASE64 was originally intended for. But whatever works, right? ;)
You can use Ascii85. Wikipedia states:
You'll find a c# implementation on github which is written by Jeff Atwood and he accompanied that code with a post on his blog
As you only need the encoder part, I used Jeff's code as a start and created an implementation with only the encoding part:
And here is the required attribution: