static public String encode ( byte [ ] bytes , String indentation ) { StringBuilder result = new StringBuilder ( ) ; int length = bytes . length ; if ( length == 0 ) return "" ; // empty byte array if ( indentation != null ) result . append ( indentation ) ; encodeByte ( bytes , 0 , result ) ; for ( int i = 1 ; i < length ; i ++ ) { if ( i % 40 == 0 ) { // format to indented 80 character blocks result . append ( "\n" ) ; if ( indentation != null ) result . append ( indentation ) ; } encodeByte ( bytes , i , result ) ; } return result . toString ( ) ; }
This function encodes a byte array using base 16 with a specific indentation of new lines .