public static String toHexString(byte[] b, int offset, int length) {
        StringBuilder buf = new StringBuilder();
        for (int i = offset; i < offset + length; i++) {
            int bi = 0xff & b[i];
            int c = '0' + (bi / 16) % 16;
            if (c > '9') {
                c = 'A' + (c - '0' - 10);
            }
            buf.append((char) c);
            c = '0' + bi % 16;
            if (c > '9') {
                c = 'a' + (c - '0' - 10);
            }
            buf.append((char) c);
        }
        return buf.toString();
    }
public static String toHexString ( byte [ ] b , int offset , int length ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = offset ; i < offset + length ; i ++ ) { int bi = 0xff & b [ i ] ; int c = '0' + ( bi / 16 ) % 16 ; if ( c > '9' ) { c = 'A' + ( c - '0' - 10 ) ; } buf . append ( ( char ) c ) ; c = '0' + bi % 16 ; if ( c > '9' ) { c = 'a' + ( c - '0' - 10 ) ; } buf . append ( ( char ) c ) ; } return buf . toString ( ) ; }
/* ------------------------------------------------------------