Boost C++ Libraries: Ticket #2010: bas64 iterator improvement https://svn.boost.org/trac10/ticket/2010 <pre class="wiki"> Hello, &gt; &gt; Code that pads base64 output with '=' looks in &gt; basic_text_oprimitive.ipp like following: &gt; &gt; std::size_t padding = 2 - count % 3; &gt; if(padding &gt; 1) &gt; *oi = '='; &gt; if(padding &gt; 2) &gt; *oi = '='; &gt; &gt; It will give the following transformations of a few simple strings: &gt; &gt; "012" -&gt; "MDEy=" &gt; "0123" -&gt; "MDEyMw" &gt; "01234" -&gt; "MDEyMzQ" &gt; "012345" -&gt; "MDEyMzQ1=" &gt; &gt; Which violates the principle of the base 64 that the encoded output &gt; length is multiple of 4 bytes. Right output for the samples above &gt; should be: &gt; &gt; "012" -&gt; "MDEy" &gt; "0123" -&gt; "MDEyMw==" &gt; "01234" -&gt; "MDEyMzQ=" &gt; "012345" -&gt; "MDEyMzQ1" &gt; &gt; &gt; The problem with the code above is that the condition (padding &gt; 2) &gt; is never satisfied. I think that the proper code should look like &gt; &gt; std::size_t padding = 2 - count % 3; &gt; if (padding &lt; 2) { &gt; *oi = '='; &gt; if (padding &gt; 0) &gt; *oi = '='; &gt; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2010 Trac 1.4.3 Robert Ramey Sat, 14 Jun 2008 16:08:04 GMT status changed https://svn.boost.org/trac10/ticket/2010#comment:1 https://svn.boost.org/trac10/ticket/2010#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Robert Ramey Thu, 11 Sep 2008 15:24:39 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2010#comment:2 https://svn.boost.org/trac10/ticket/2010#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> change checked into trunk </p> Ticket