public static String encode(byte barr[]){
  StringBuilder rtn=new StringBuilder();
  int len=barr.length;
  int read=0;
  boolean stop=false;
  byte b=0;
  int offset=0;
  do {
    int left=len - read;
    if (left == 0)     stop=true;
    if (left <= 45)     b=(byte)left;
 else     b=45;
    rtn.append(_enc(b));
    for (int i=0; i < b; i+=3) {
      if (len - offset < 3) {
        byte padding[]=new byte[3];
        for (int z=0; offset + z < len; z++)         padding[z]=barr[offset + z];
        encodeBytes(padding,0,rtn);
      }
 else {
        encodeBytes(barr,offset,rtn);
      }
      offset+=3;
    }
    rtn.append('\n');
    read+=b;
    if (b < 45)     stop=true;
  }
 while (!stop);
  return rtn.toString();
}

public static String encode ( byte barr [ ] ) { StringBuilder rtn = new StringBuilder ( ) ; int len = barr . length ; int read = 0 ; boolean stop = false ; byte b = 0 ; int offset = 0 ; do { int left = len - read ; if ( left == 0 ) stop = true ; if ( left <= 45 ) b = ( byte ) left ; else b = 45 ; rtn . append ( _enc ( b ) ) ; for ( int i = 0 ; i < b ; i += 3 ) { if ( len - offset < 3 ) { byte padding [ ] = new byte [ 3 ] ; for ( int z = 0 ; offset + z < len ; z ++ ) padding [ z ] = barr [ offset + z ] ; encodeBytes ( padding , 0 , rtn ) ; } else { encodeBytes ( barr , offset , rtn ) ; } offset += 3 ; } rtn . append ( '\n' ) ; read += b ; if ( b < 45 ) stop = true ; } while ( ! stop ) ; return rtn . toString ( ) ; }
encodes a byte array to a string
