def numToHex(num, numBytes):
    "\n        Given a number returns its hexadecimal format with the specified length, adding '\x00' if necessary\n\n        @param num: A number (int)\n        @param numBytes: Length of the output (int)\n        @return: A tuple (status,statusContent), where statusContent is a number in hexadecimal format in case status = 0 or an error in case status = -1\n    "
    hexString = ''
    if not isinstance(num, int):
        return -1, 'Bad number'
    try:
        hexNumber = hex(num)[2:]
        if len(hexNumber) % 2 != 0:
            hexNumber = '0' + hexNumber
        for i in range(0, len(hexNumber) - 1, 2):
            hexString += chr(int(hexNumber[i] + hexNumber[i + 1], 16))
        hexString = '\x00' * (numBytes - len(hexString)) + hexString
    except:
        return -1, 'Error in hexadecimal conversion'
    return 0, hexString
