盘绰网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

Base64,enjoy!

时间:2024/12/17作者:未知来源:盘绰网教程人气:


[摘要]codes[ data[ix] ] < 0 )--tempLen;// ignore non-valid chars and padding// calculate required leng...
codes[ data[ix] ] < 0 )
--tempLen;// ignore non-valid chars and padding
}
// calculate required length:
//-- 3 bytes for every 4 valid base64 chars
//-- plus 2 bytes if there are 3 extra base64 chars,
// or plus 1 byte if there are 2 extra.

int len = (tempLen / 4) * 3;
if ((tempLen % 4) == 3) len += 2;
if ((tempLen % 4) == 2) len += 1;

byte[] out = new byte[len];



int shift = 0; // # of excess bits stored in accum
int accum = 0; // excess bits
int index = 0;

// we now go through the entire array (NOT using the 'tempLen' value)
for (int ix=0; ix<data.length; ix++)
{
int value = (data[ix]>255)? -1: codes[ data[ix] ];

if ( value >= 0 ) // skip over non-code
{
accum <<= 6;// bits shift up by 6 each time thru
shift += 6; // loop, with new bits being put in
accum

关键词:  Base64  enjoy!





Copyright © 2012-2018 盘绰网教程(http://www.panchuo.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版