<p>你得到的第一个样本是无效的base64。在</p>
<p>摘自维基:</p>
<blockquote>
<p>When the number of bytes to encode is not divisible by 3 (that is, if there are only one or two bytes of input for the last block), then the following action is performed: Add extra bytes with value zero so there are three bytes, and perform the conversion to base64. If there was only one significant input byte, only the first two base64 digits are picked, and if there were two significant input bytes, the first three base64 digits are picked. '=' characters might be added to make the last block contain four base64 characters.</p>
</blockquote>
<p><a href="http://en.wikipedia.org/wiki/Base64#Examples" rel="nofollow">http://en.wikipedia.org/wiki/Base64#Examples</a></p>
<p>编辑:</p>
<p>摘自RFC 4648:</p>
<blockquote>
<p>Special processing is performed if fewer than 24 bits are available<br/>
at the end of the data being encoded. A full encoding quantum is<br/>
always completed at the end of a quantity. When fewer than 24 input<br/>
bits are available in an input group, bits with value zero are added<br/>
(on the right) to form an integral number of 6-bit groups. Padding<br/>
at the end of the data is performed using the '=' character.</p>
</blockquote>
<p>4乘以8bits(the='s)(在你的<code>sample</code>末尾)超过了24位,所以它们至少是不必要的。(不确定<code>sample</code>是什么数据类型,但找出它的大小乘以字符数除以24)</p>
<p>关于您的特定<code>sample</code>:</p>
<p>基本编码读取24位块,只需要在基字符串末尾添加“=”填充字符,就可以使将字符串拆分为24位块后剩下的部分变为“24大小”,这样解码器就可以对其进行解析。
由于字符串末尾的====值超过24位,因此它们是无用的,因此:无效。。。在</p>