public static String byteArrayToHex(final byte[] data,final int offset,final int length){
  final StringBuffer buf=new StringBuffer();
  for (int i=offset; i < offset + length; i++) {
    int halfbyte=(data[i] >>> 4) & 0x0F;
    int twohalfs=0;
    do {
      if ((0 <= halfbyte) && (halfbyte <= 9)) {
        buf.append((char)('0' + halfbyte));
      }
 else {
        buf.append((char)('a' + (halfbyte - 10)));
      }
      halfbyte=data[i] & 0x0F;
    }
 while (twohalfs++ < 1);
  }
  return buf.toString();
}

public static String byteArrayToHex ( final byte [ ] data , final int offset , final int length ) { final StringBuffer buf = new StringBuffer ( ) ; for ( int i = offset ; i < offset + length ; i ++ ) { int halfbyte = ( data [ i ] > > > 4 ) & 0x0F ; int twohalfs = 0 ; do { if ( ( 0 <= halfbyte ) && ( halfbyte <= 9 ) ) { buf . append ( ( char ) ( '0' + halfbyte ) ) ; } else { buf . append ( ( char ) ( 'a' + ( halfbyte - 10 ) ) ) ; } halfbyte = data [ i ] & 0x0F ; } while ( twohalfs ++ < 1 ) ; } return buf . toString ( ) ; }
converte un array di byte in una stringa che ne rappresenta il contenuto in formato esadecimale .
