The Base32 encoding specification states that a inputs bitlength must be a multiple of 5. In your Base32Converter, you do the following check:
int mod = buffer.Length % 3;
if (mod != 0) {
throw new InvalidOperationException("...");
}
This seems wrong. The bit length of a byte[] array should be buffer.Length * 8 (there are 8 bits per byte), and then you should check the bit length. This seems more correct.
int bitLength = buffer.Length * 8;
int bitsNotProvided = bitLength % 5;
if (bitsNotProvided != 0) {
throw new InvalidOperationException("...");
}
However also, the specification states that you really should pad the input with 0's for the number of bits that were not provided. I am hoping to get your response on this, and correct me if I am wrong? I am writing my own Base32Encoding for learning purposes
and for use in my own licensing scheme, but there seems to be some issues that contradict the specification in your Base32Converter.
