/** * 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 div-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)