Return a hexadecimal representation of a byte array
@param b a byte array
@return String containing the hexadecimal representation
327279
public final static String toHex(byte [] b) {
	char[] buf = new char[b.length * 2];
	int i, j, k;

	i = j = 0;
	for (; i < b.length; i++) {
	    k = b[i];
	    buf[j++] = hex[(k >>> 4) & 0x0F];
	    buf[j++] = hex[ k & 0x0F];
	}
	return new String(buf);
    }
893090
public static String byteArrayToString(byte[] b) {
       final int l = b.length/2;
       if (l*2 != b.length) throw new IllegalArgumentException();
       StringBuffer result = new StringBuffer(l);
       int o = 0;
       for (int i = 0; i < l; i++)
       {
           int i1 = b[o++] & 0xff;
           int i2 = b[o++] & 0xff;
           i2 = i2 << 8;
           i1 = i1 | i2;
           result.append((char)i1);
       }
       return (result.toString());
    }
724703
public static long toLong(byte[] b) {
        return ((((long) b[7]) & 0xFF)
                + ((((long) b[6]) & 0xFF) << 8)
                + ((((long) b[5]) & 0xFF) << 16)
                + ((((long) b[4]) & 0xFF) << 24)
                + ((((long) b[3]) & 0xFF) << 32)
                + ((((long) b[2]) & 0xFF) << 40)
                + ((((long) b[1]) & 0xFF) << 48)
                + ((((long) b[0]) & 0xFF) << 56));
    }
383876
private static String byteToHexString(byte[] bytes)
  {
    final char[] hexArray = "0123456789ABCDEF".toCharArray();
    char[] hexChars = new char[bytes.length * 2];
    for (int j = 0; j < bytes.length; j++)
    {
      int v = bytes[j] & 0xFF;
      hexChars[j * 2] = hexArray[v >>> 4];
      hexChars[j * 2 + 1] = hexArray[v & 0x0F];
    }
    return new String(hexChars);
  }
819006
public static String byteArrayToHexString(byte[] b) {

        int    len = b.length;
        char[] s   = new char[len * 2];

        for (int i = 0, j = 0; i < len; i++) {
            int c = ((int) b[i]) & 0xff;

            s[j++] = (char) HEXBYTES[c >> 4 & 0xf];
            s[j++] = (char) HEXBYTES[c & 0xf];
        }

        return new String(s);
    }
826844
public static String hex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEXES_SMALL[v >>> 4];
            hexChars[j * 2 + 1] = HEXES_SMALL[v & 0x0F];
        }
        return new String(hexChars);
    }
621767
public static String toHexString(byte in[]) {
		if(in == null || in.length <= 0) {
			return null;
		}

		int i = 0;
		byte ch = 0x00;
		String pseudo[] = {
				"0", "1", "2", "3",
				"4", "5", "6", "7",
				"8", "9", "A", "B",
				"C", "D", "E", "F"
		};

		StringBuffer out = new StringBuffer(in.length * 2);
		while(i < in.length) {
			ch = (byte)(in[i] & 0xF0);		// Strip off high nibble
			ch = (byte)(ch >>> 4);			// shift the bits down
			ch = (byte)(ch & 0x0F);			// must do this is high order bit is on!
			out.append(pseudo[(int)ch]);	// convert the nibble to a String Character
			ch = (byte)(in[i] & 0x0F);		// Strip off low nibble 
			out.append(pseudo[(int)ch]);	// convert the nibble to a String Character
			out.append(' ');
			i++;
		}

		return new String(out);
	}
1057431
public String toHexString() {
		byte[] bytes = this.data.array();
		char[] hex = new char[this.data.remaining() * 2];
		for (int i = this.data.position(); i < this.data.remaining(); i++) {
			int b = bytes[i] & 0xFF;
			hex[i * 2] = HEX_CHARS[b >>> 4];
			hex[i * 2 + 1] = HEX_CHARS[b & 0x0F];
		}
		return new String(hex);
	}
1083197
public static String toHexString(byte[] bytes, int start, int len) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int b = bytes[start + i] & 0xFF;
            if (b < 16) buf.append('0');
            buf.append(Integer.toHexString(b));
        }
        return buf.toString();
    }
261067
private static String getHexString(byte[] bytes) {

        // If null byte array given, return null
        if (bytes == null)
            return null;

        // Create string builder for holding the hex representation,
        // pre-calculating the exact length
        StringBuilder hex = new StringBuilder(2 * bytes.length);

        // Convert each byte into a pair of hex digits
        for (byte b : bytes) {
            hex.append(HEX_CHARS[(b & 0xF0) >> 4])
               .append(HEX_CHARS[ b & 0x0F      ]);
        }

        // Return the string produced
        return hex.toString();

    }
974001
public final String toHexString() {
		if (this.hexString == null) {
			final byte[] ba = new byte[SIZE];
			longToByteArray(this.lowerPart, ba, 0);
			longToByteArray(this.upperPart, ba, SIZE_OF_LONG);

			this.hexString = StringUtils.byteToHexString(ba);
		}

		return this.hexString;
	}
119120
public static String _2_16(byte[] bytes) {

        if (bytes == null || bytes.length == 0)
            return null;

        StringBuilder sb = new StringBuilder();
        for (byte aByte : bytes) {
            String hex = Integer.toHexString(aByte & 0xFF);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }
            sb.append(hex.toUpperCase());
        }
        return sb.toString();
    }
1290772
public static final long toLong(byte[] b) {
        long x = 0;
        for (int i = b.length; i > 0; x |= (b[--i] & 0xffL) << (i << 3));
        return x;
    }
780290
public String toHexString() {
    final StringBuffer sb = new StringBuffer();
    for (final byte b : this.bytes) {
      sb.append(Integer.toHexString(b & 0xFF));
    }
    return sb.substring(0, Math.min(this.bitLength / 4, sb.length()));
  }
169567
public static String toHex(final byte[] bytes) {
        if (bytes == null) {
            return "";
        }
        StringBuffer sb = new StringBuffer(bytes.length * 2);
        for (byte b : bytes) {
            appendHex(sb, b);
        }
        return sb.toString();
    }
144714
public static String toHexString(byte[] bytes, boolean isHNF) {
    StringBuilder sb = new StringBuilder();
    for (byte b : bytes) {
      String hex =
          String.format("%2s", Integer.toHexString(b & 0xFF)).replace(' ', '0');
      if (isHNF)
        sb.append(hex);
      else
        sb.append(new StringBuilder(hex).reverse());
    }
    return sb.toString();
  }
724861
public static String encodeHexString(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }