首页/技术开发/内容

Base64,enjoy!

技术开发2024-12-17 阅读()
[摘要]= (0xFF & (int) data[i+2]);quad = true;out[index+3] = alphabet[(quad? (val & 0x3F): 64)];va...
= (0xFF & (int) data[i+2]);
quad = true;
}
out[index+3] = alphabet[(quad? (val & 0x3F): 64)];
val >>= 6;
out[index+2] = alphabet[(trip? (val & 0x3F): 64)];
val >>= 6;
out[index+1] = alphabet[val & 0x3F];
val >>= 6;
out[index+0] = alphabet[val & 0x3F];
}
return out;
}

/**
 * Decodes a BASE-64 encoded stream to recover the original
 * data. White space before and after will be trimmed away,
 * but no other manipulation of the input will be performed.
 *
 * As of version 1.2 this method will properly handle input
 * containing junk characters (newlines and the like) rather
 * than throwing an error. It does this by pre-parsing the
 * input and generating from that a count of VALID input
 * characters.
 **/
static public byte[] decode(char[] data)
{
// as our input could contain non-BASE64 data (newlines,
// whitespace of any sort, whatever) we must first adjust
// our count of USABLE data so that...
// (a) we don't misallocate the output array, and
// (b) think that we miscalculated our data length
// just because of extraneous throw-away junk

int tempLen = data.length;
for( int ix=0; ix<data.length; ix++ )
{
if( (data[ix] > 255) (北联网教程,专业提供视频软件下载)

第1页  第2页  第3页  第4页  第5页  第6页 

……

相关阅读