Takes a byte array and returns a hex string (00-FF) encoded two chars per byte.
420917
public static String encodeBytesToString(byte bytes[]) {
    StringBuilder string = new StringBuilder(bytes.length * 2);
    for (int i = 0; i < bytes.length; i++) {
      // look up high nibble char
      string.append(hexChar[(bytes[i] & 0xf0) >>> 4]);
      // look up low nibble char
      string.append(hexChar[bytes[i] & 0x0f]);
    }
    return string.toString();
  }
918583
public static String toHexString(byte[] b) {
       StringBuffer result = new StringBuffer(b.length * 2);
       for (int i = 0; i < b.length; i++) {
          result.append(digits.charAt((b[i] >> 4) & 0xf));
          result.append(digits.charAt(b[i] & 0xf));
       }
       return (result.toString());
    }
174518
public static byte[] decodeHex(final String data) {

        checkNotNull("data", data);

        final int len = data.length();

        if ((len & 0x01) != 0) {
            throw new RuntimeException("Odd number of characters.");
        }

        final byte[] out = new byte[len >> 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; j < len; i++) {
            int f = toDigit(data.charAt(j), j) << 4;
            j++;
            f = f | toDigit(data.charAt(j), j);
            j++;
            out[i] = (byte) (f & 0xFF);
        }

        return out;
    }
688135
static String hex0(final byte x) {
        final char tab[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                'a', 'b', 'c', 'd', 'e', 'f' };
        int uint;
        if (x < 0) {
            uint = x & 0x7F;
            uint |= 1 << 7;
        } else {
            uint = x;
        }
        return "" + tab[uint >>> 4] + tab[uint & 0xF];
    }
158344
def hex(self):
        """"""
        addrstr = '000000'
        if self.addr is not None:
            addrstr = binascii.hexlify(self.addr).decode()
        return addrstr
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);
	}
920729
def to_hex_string(data):
    '''  '''
    if isinstance(data, int):
        return '%02X' % data
    return ':'.join([('%02X' % o) for o in data])
714803
function byteArray2hexStr(byteArray) {
  var str = "";
  for (var i = 0; i < (byteArray.length - 1); i++) {
    str += byte2hexStr(byteArray[i]);
  }
  str += byte2hexStr(byteArray[i]);
  return str;
}
237292
public static String toHexString(byte[] b) {
        if (b == null)
            return null;

        StringBuilder sb = new StringBuilder(b.length * 2);
        for (int i = 0; i < b.length; i++) {
            int v = b[i] & 0xFF;
            String hv = Integer.toHexString(v);
            if (hv.length() < 2) {
                sb.append(0);
            }
            sb.append(hv);
        }
        return sb.toString();
    }
563074
function hexStr2byteArray(str) {
  var byteArray = Array();
  var d = 0;
  var j = 0;
  var k = 0;

  for (let i = 0; i < str.length; i++) {
    var c = str.charAt(i);
    if (isHexChar(c)) {
      d <<= 4;
      d += hexChar2byte(c);
      j++;
      if (0 === (j % 2)) {
        byteArray[k++] = d;
        d = 0;
      }
    }
  }
  return byteArray;
}
659862
public static byte[] hex2byte(String hex) {
		byte[] ret = new byte[8];
		byte[] tmp = hex.getBytes();
		for (int i = 0; i < 8; i++) {
			ret[i] = uniteBytes(tmp[i * 2], tmp[i * 2 + 1]);
		}
		return ret;
	}
974072
public static byte[] fromHex(String hex) {
		char[] c = hex.toCharArray();
		byte[] b = new byte[c.length / 2];
		for (int i = 0; i < b.length; i ++) {
			b[i] = (byte) (HEX_DECODE_CHAR[c[i * 2] & 0xFF] * 16 +
					HEX_DECODE_CHAR[c[i * 2 + 1] & 0xFF]);
		}
		return b;
	}
676516
@Nonnull
    public static String toHex(@Nonnull final byte[] bytes) {
        StringBuilder buf = new StringBuilder(bytes.length * 2);
        for (byte b : bytes) {
            String hexDigits = Integer.toHexString((int) b & 0x00ff);
            if (hexDigits.length() == 1) {
                buf.append('0');
            }
            buf.append(hexDigits);
        }
        return buf.toString();
    }
997901
private static byte[] hexStringToByteArray(String s)
	{
		byte[] b = new byte[s.length() / 2];
		for (int i = 0; i < b.length; i++)
		{
			int index = i * 2;
			int v = Integer.parseInt(s.substring(index, index + 2), 16);
			b[i] = (byte) v;
		}
		return b;
	}
1321786
public static char[] binToHex(byte[] bytes, int offset, int len) {
        final char[] sb = new char[len * 2];
        final int end = offset + len;
        int index = 0;
        final char[] hexs = hex;
        for (int i = offset; i < end; i++) {
            byte b = bytes[i];
            sb[index++] = (hexs[((b >> 4) & 0xF)]);
            sb[index++] = hexs[((b) & 0xF)];
        }
        return sb;
    }
1136311
private static String byte2hex(byte[] b) {
		StringBuilder hs = new StringBuilder();
		String stmp;
		for (int n = 0; b!=null && n < b.length; n++) {
			stmp = Integer.toHexString(b[n] & 0XFF);
			if (stmp.length() == 1)
				hs.append('0');
			hs.append(stmp);
		}
		return hs.toString().toUpperCase();
	}
974374
function toHexString(number, numberOfBytes) {
  numberOfBytes = numberOfBytes || 1;
  let hexString = '00'.repeat(numberOfBytes) + number.toString(16);

  return hexString.substr(-2 * numberOfBytes);
}