Convert the given number to a hexadecimal string of the given length.
@param {Number} number The given number.
@param {Number} numberOfBytes The number of bytes of hex string.
@return {String} The resulting hexadecimal string.
974374
function toHexString(number, numberOfBytes) {
  numberOfBytes = numberOfBytes || 1;
  let hexString = '00'.repeat(numberOfBytes) + number.toString(16);

  return hexString.substr(-2 * numberOfBytes);
}
532834
public static String intToHex(int number, int hexSize) {
        String tmp = Integer.toHexString(number & 0xFF);
        while (tmp.length() < hexSize) {
            tmp = "0" + tmp;
        }
        return tmp;
    }
260846
private static Object toExternalNumber( BigDecimal number)
    {
    return
      Optional.ofNullable(
        toObject(
          number,
          ObjectUtils::toInt,
          ObjectUtils::toLong))

      .orElse( number);
    }
425523
function(dec, bytes) {
    var hex = "",
        i;
    for (i = 0; i < bytes; i++) {
        hex += String.fromCharCode(dec & 0xff);
        dec = dec >>> 8;
    }
    return hex;
}
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();
	}
907870
public static BigDecimal toBigDecimal(String number) {
		return (null == number) ? BigDecimal.ZERO : new BigDecimal(number);
	}
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);
  }
255285
function toHexString(buffer, options) {
        options = options || {};
        var prefix = options.prefix || '', digits, idx;

        if ((options.format || 'BE') !== 'BE') {
            _reverseBuffer(buffer);
        }

        digits = buffer.toString('hex');
        idx = _lastHeadIndex(digits, '0');

        // if there are only 0's use the last digit
        idx = idx >= 0 ? idx : digits.length - 1;

        return prefix + _pad(
            _split(digits.slice(idx), options.groupsize, options.delimiter), prefix, options.padstr, options.size);
    }
1343597
public String readString(final int numberOfBytes) {
    position += numberOfBytes;
    return new String(buf, position - numberOfBytes, numberOfBytes);
  }
187277
function(n){
  if(typeof n === 'number'){
    return n;
  }
  if(typeof n !== 'string'){
    n = JSON.stringify(n)
  }
  var res = 0;
  n.split("").map(function(bit){
    res += bit.charCodeAt(0);
  });
  return res;
}
1017556
function binToHex(binArray){
        var hexString = "0123456789abcdef",
            str = "",
            i;

        for(i = 0; i < binArray.length * 4; i++){
            str += hexString.charAt((binArray[i >> 2] >> ((3 - i % 4) * 8 + 4)) & 0xF) +
                    hexString.charAt((binArray[i >> 2] >> ((3 - i % 4) * 8  )) & 0xF);
        }

        return str;
    }
309767
function fromString(str) {
  const bytes = [];

  for (let n = 0, l = str.length; n < l; n++) {
    const hex = Number(str.charCodeAt(n)).toString(16);
    bytes.push(hex);
  }

  return '0x' + bytes.join('');
}
201393
private static String bytesToHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            int v = bytes[i] & 0xFF;
            hexChars[i * 2] = hexArray[v >>> 4];
            hexChars[i * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
1020808
function encodeNumber(buf, value, len) {
  var index = 0;
  
  while (len > 0) {
    var tmpValue = value >>> ((len - 1) * 8);
    buf[index++] = tmpValue & 0xFF;
    len--;
  }
}
27729
function (num) {
            var value, encoded = '';
            while (num >= 0x20) {
                value = (0x20 | (num & 0x1f)) + 63;
                encoded += (String.fromCharCode(value));
                num >>= 5;
            }
            value = num + 63;
            encoded += (String.fromCharCode(value));

            return encoded;
        }
506129
function toHex(bignum) {
      var tmp0 = bignum[0] < 0 ? (bignum[0]>>>0) : bignum[0];
      var tmp1 = bignum[1] < 0 ? (bignum[1]>>>0) : bignum[1];
      return tmp0.toString(16) + tmp1.toString(16);
    }
531171
function BigNumber(number) {
    this.numberStr = number.toString();

    // not a number
    if (isNaN(parseFloat(this.numberStr)) === true
        || isFinite(this.numberStr) === false) {
        throw new Error(number + ' is not a number');
    }
}