Encodes an array of bytes as hex symbols.

@param bytes
the array of bytes to encode
@param offset
the start offset in the array of bytes
@param length
the number of bytes to encode
@return the resulting hex string
485671
public static String toHex(byte[] bytes, int offset, int length) {
      return toHex(bytes, offset, length, null);
   }
274814
public static String toHex(byte[] bytes) {
		StringBuilder hexString=new StringBuilder();
		for (int i=0; i<bytes.length; i++) {

			String hex=Integer.toHexString(0xFF & bytes[i]);
			if (hex.length() == 1) {
				hexString.append('0');
			}

			hexString.append(hex);
		}

		return hexString.toString();
	}
307638
function(bytes) {
      for (var hex = [], i = 0; i < bytes.length; i++) {
        hex.push((bytes[i] >>> 4).toString(16));
        hex.push((bytes[i] & 0xF).toString(16));
      }
      return hex.join('');
    }
835792
public static long bytes_to_long(byte[] bytes, int offset) {
		if(bytes.length-offset<8)
			throw new PickleException("too few bytes to convert to long");
		long i = bytes[7+offset] & 0xff;
		i <<= 8;
		i |= bytes[6+offset] & 0xff;
		i <<= 8;
		i |= bytes[5+offset] & 0xff;
		i <<= 8;
		i |= bytes[4+offset] & 0xff;
		i <<= 8;
		i |= bytes[3+offset] & 0xff;
		i <<= 8;
		i |= bytes[2+offset] & 0xff;
		i <<= 8;
		i |= bytes[1+offset] & 0xff;
		i <<= 8;
		i |= bytes[offset] & 0xff;
		return i;
	}
268433
public static void writeInt(byte[] bytes, int value, int offset) {
        bytes[offset] = (byte) (0xFF & (value >> 24));
        bytes[offset + 1] = (byte) (0xFF & (value >> 16));
        bytes[offset + 2] = (byte) (0xFF & (value >> 8));
        bytes[offset + 3] = (byte) (0xFF & value);
    }
410747
public static String encode(byte[] bytes)
    {
        StringBuilder sb = new StringBuilder(bytes.length << 1);
        for (byte aByte : bytes)
        {
            sb.append(convertDigit(aByte >> 4));
            sb.append(convertDigit(aByte & 0x0f));
        }
        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();
  }
728488
public static final String toHex(byte[] buf, int offset, int length)
    {
        return toHex(Arrays.copyOfRange(buf, offset, offset+length));
    }
896637
public static void dumpHex(StringBuilder s, byte[] buffer, int offset, int length) {
		dumpHex(s, ByteBuffer.wrap(buffer, offset, length));
	}
127348
private static String byteArrayToHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * 2);
        for (byte element : bytes) {
            int v = element & 0xff;
            if (v < 16) {
                sb.append('0');
            }
            sb.append(Integer.toHexString(v));
        }
        return sb.toString();
    }
185889
public static char bytesToChar(byte[] bytes, int offset) {
        char result = 0x0;
        for (int i = offset; i < offset + 2; ++i) {
            result = (char) ((result) << 8);
            result |= (bytes[i] & 0x00FF);
        }
        return result;
    }
626648
public static byte[] convertHexStringToBytes(String hexString, int offset,
            int endIndex) {
        byte[] data;
        String realHexString = hexString.substring(offset, endIndex)
                .toLowerCase();
        if ((realHexString.length() % 2) == 0)
            data = new byte[realHexString.length() / 2];
        else
            data = new byte[(int)Math.ceil(realHexString.length() / 2d)];

        int j = 0;
        char[] tmp;
        for (int i = 0; i < realHexString.length(); i += 2) {
            try {
                tmp = realHexString.substring(i, i + 2).toCharArray();
            } catch (StringIndexOutOfBoundsException siob) {
                // it only contains one character, so add "0" string
                tmp = (realHexString.substring(i) + "0").toCharArray();
            }
            data[j] = (byte)((Arrays.binarySearch(hexChar, tmp[0]) & 0xf) << 4);
            data[j++] |= (byte)(Arrays.binarySearch(hexChar, tmp[1]) & 0xf);
        }

        for (int i = realHexString.length(); i > 0; i -= 2) {

        }
        return data;
    }
771502
public static String toHex(byte[] bytes) {
    StringBuffer buffer = new StringBuffer();

    for (byte b : bytes) {
      buffer.append(String.format("%02X", b));
    }

    return buffer.toString();
  }
1016096
public static String hexDump(ByteBuf buffer, int fromIndex, int length) {
        return HexUtil.hexDump(buffer, fromIndex, length);
    }
775398
public static byte[] hexToByteArray(String hex) {
    int length = hex.length();
    byte[] result = new byte[(length / 2) + (length % 2)];
    for (int i = length, j = result.length - 1; i > 0; i -= 2, j--) {
      result[j] = hexToByte(hex.charAt(i - 1));
      if (i > 1) {
        result[j] |= (hexToByte(hex.charAt(i - 2)) << 4);
      }
    }
    return result;
  }
293281
private static void encodeCopy(ByteBuf out, int offset, int length) {
        while (length >= 68) {
            encodeCopyWithOffset(out, offset, 64);
            length -= 64;
        }

        if (length > 64) {
            encodeCopyWithOffset(out, offset, 60);
            length -= 60;
        }

        encodeCopyWithOffset(out, offset, length);
    }
370213
public static int bytesToInt(byte[] bytes, int offset) {
        return ((bytes[offset + 3] & 0xFF) << 0) + ((bytes[offset + 2] & 0xFF) << 8)
                        + ((bytes[offset + 1] & 0xFF) << 16) + ((bytes[offset + 0] & 0xFF) << 24);
    }