Thanks Wei! To go with the patch, I've added a base32 class based on the hex class. It works like the old one, except that it defaults to upper case. You can use lower case via a parameter, just like hex. I've only tested it a little, but it seems to work fine.
-Frank -----Original Message----- From: Wei Dai [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 7:47 PM To: [EMAIL PROTECTED] Subject: Re: Bug in BaseN_Encoder Thanks for reporting this bug. I've attached a patch to fix the bug. On Wed, Jan 15, 2003 at 11:54:00AM -0800, [EMAIL PROTECTED] wrote: > > Hello, > > I was testing a Base32 class and I found a problem with BaseN_Encoder > class. It only supports bit widths of 4, 6, and 7 correctly. The > existing Base64 and Hex Encoding work fine, but I tried Base32 and it > unfortunately demonstrates the problem. > > With 5 bits per pixel, it is possible for one input byte to contribute > to parts of 3 encoded characters: > > Input Byte: > 01 - 10011 - 0 > > BaseN_Encoder only supports a maximum of 2... > > >From BaseN_Encoder::Put2(): > > m_outBuf[m_bytePos] |= begin[m_inputPosition] >> (8-m_bitsPerChar+m_bitPos); > m_outBuf[m_bytePos+1] |= ((begin[m_inputPosition] << (m_bitsPerChar-m_bitPos)) & > 0xff) >> (8-m_bitsPerChar); > ++m_inputPosition; > > For Base64 and Hex Encoding, this case doesn't occur. (3 6-bit Base64 > chars can't come from one byte, and Hex characters are always framed > such that there are exactly 2 per byte. > > For 7 bits per char, it will work correctly as coded. > But.. > For 3 or 5 bits per char encodings, there needs to be support for 3 > chars per input byte For 2 bits per char, 4 would be required For 1 > bit per char, 8 would be required > > Thanks, > Frank
base32.zip
Description: Binary data
