@Override public byte[] decode(final byte[] valuesRead){
  int special_cases=0, returns=0, data_size=valuesRead.length;
  for (int i=0; i < data_size; i++) {
    if (valuesRead[i] == 122) {
      special_cases++;
    }
 else     if (valuesRead[i] == 10) {
      returns++;
    }
  }
  if (returns == 5 && special_cases == 0 && ((data_size - returns) % 5) == 4) {
    data_size++;
  }
  int output_pointer=0;
  long value;
  final byte[] temp_data=new byte[data_size - returns + 1 + (special_cases * 3)];
  int ii, next;
  for (int i=0; i < data_size; i++) {
    value=0;
    next=valuesRead[i];
    while ((next == 10) || (next == 13)) {
      i++;
      if (i == data_size) {
        next=0;
      }
 else {
        next=valuesRead[i];
      }
    }
    if (next == 122) {
      for (int i3=0; i3 < 4; i3++) {
        temp_data[output_pointer]=0;
        output_pointer++;
      }
    }
 else     if ((data_size - i > 4) && (next > 32) && (next < 118)) {
      int cut=4;
      for (ii=0; ii < 5; ii++) {
        if (i < valuesRead.length) {
          next=valuesRead[i];
        }
        while ((next == 10) || (next == 13)) {
          i++;
          if (i == data_size) {
            next=0;
          }
 else {
            next=valuesRead[i];
          }
        }
        i++;
        if (next == 126 && valuesRead[i] == 62) {
          cut=ii - 1;
        }
        if (((next > 32) && (next < 118)) || (next == 126)) {
          value+=((next - 33) * base_85_indices[ii]);
        }
      }
      for (int i3=0; i3 < 4 && i3 < cut; i3++) {
        temp_data[output_pointer]=(byte)((value / hex_indices[i3]) & 255);
        output_pointer++;
      }
      i--;
    }
  }
  final byte[] processed_data=new byte[output_pointer];
  System.arraycopy(temp_data,0,processed_data,0,output_pointer);
  return processed_data;
}

@ Override public byte [ ] decode ( final byte [ ] valuesRead ) { int special_cases = 0 , returns = 0 , data_size = valuesRead . length ; for ( int i = 0 ; i < data_size ; i ++ ) { if ( valuesRead [ i ] == 122 ) { special_cases ++ ; } else if ( valuesRead [ i ] == 10 ) { returns ++ ; } } if ( returns == 5 && special_cases == 0 && ( ( data_size - returns ) % 5 ) == 4 ) { data_size ++ ; } int output_pointer = 0 ; long value ; final byte [ ] temp_data = new byte [ data_size - returns + 1 + ( special_cases * 3 ) ] ; int ii , next ; for ( int i = 0 ; i < data_size ; i ++ ) { value = 0 ; next = valuesRead [ i ] ; while ( ( next == 10 ) || ( next == 13 ) ) { i ++ ; if ( i == data_size ) { next = 0 ; } else { next = valuesRead [ i ] ; } } if ( next == 122 ) { for ( int i3 = 0 ; i3 < 4 ; i3 ++ ) { temp_data [ output_pointer ] = 0 ; output_pointer ++ ; } } else if ( ( data_size - i > 4 ) && ( next > 32 ) && ( next < 118 ) ) { int cut = 4 ; for ( ii = 0 ; ii < 5 ; ii ++ ) { if ( i < valuesRead . length ) { next = valuesRead [ i ] ; } while ( ( next == 10 ) || ( next == 13 ) ) { i ++ ; if ( i == data_size ) { next = 0 ; } else { next = valuesRead [ i ] ; } } i ++ ; if ( next == 126 && valuesRead [ i ] == 62 ) { cut = ii - 1 ; } if ( ( ( next > 32 ) && ( next < 118 ) ) || ( next == 126 ) ) { value += ( ( next - 33 ) * base_85_indices [ ii ] ) ; } } for ( int i3 = 0 ; i3 < 4 && i3 < cut ; i3 ++ ) { temp_data [ output_pointer ] = ( byte ) ( ( value / hex_indices [ i3 ] ) & 255 ) ; output_pointer ++ ; } i -- ; } } final byte [ ] processed_data = new byte [ output_pointer ] ; System . arraycopy ( temp_data , 0 , processed_data , 0 , output_pointer ) ; return processed_data ; }
ascii85decode using our own implementation
