Hi,

  I have discovered strange behavior of XSCryptCryptoBase64::encode
 in VisualC++.net.
  When I create xsec_1_0_0.dll in debug mode everything is ok
- encode works perfect, but when I have create release version....
something strange happend. Encode starts to create wrong output!! 
I have lost, lets say, 'some time' to discover that mistakes come from
this code:


                // First 6 bits;
                t = (m_inputBuffer[i] >> 2);

                // 2 bits from byte one and 4 from byte 2
                t = ((m_inputBuffer[i++] << 4) & 0x30) |
(m_inputBuffer[i] >> 4);
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];

                // 4 from byte 2 and 2 from byte 3
                t = ((m_inputBuffer[i++] << 2) & 0x3C) |
(m_inputBuffer[i] >> 6);
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];

                // last 6 bits from byte 3
                t = m_inputBuffer[i++] & 0x3F;
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];


The problem is/was with '|' operator (I suppose).
So I have corrected this into something like that:

                // First 6 bits;
                t = (m_inputBuffer[i] >> 2);

                // 2 bits from byte one and 4 from byte 2
                //t = ((m_inputBuffer[i++] << 4) & 0x30) |
(m_inputBuffer[i] >> 4);
                t = ((m_inputBuffer[i] << 4) & 0x30);
                t |= (m_inputBuffer[i+1] >> 4);
                i++;
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];

                // 4 from byte 2 and 2 from byte 3
                //t = ((m_inputBuffer[i++] << 2) & 0x3C) |
(m_inputBuffer[i] >> 6);
                t = ((m_inputBuffer[i] << 2) & 0x3C);
                t |= (m_inputBuffer[i+1] >> 6);
                i++;
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];

                // last 6 bits from byte 3
                t = m_inputBuffer[i++] & 0x3F;
                m_outputBuffer[m_remainingOutput++] =
Base64LookupTable[t];


I know, that this is not 'a beautiful' code, but it works.
And here is my question: have I something wrong (wrong opitions,
declaration, etc.)
in my release project configuration in Visual? Maybe this is relevant to
type conversions?


  Best regards,
  AndrzeJ

Reply via email to