def int2data(int1, padded=0):
    """
    Converts integer into hex data.
    int1 = integer to convert into data
    padded = number of bytes necessary. Will pad msb with 0 bytes. If 0, no padding.
    """
    if type(padded) is not int:
        return None
    padstr = '' if padded <= 0 else '0' + str(padded * 2)
    formatstr = '%' + padstr + 'x'
    hexstr = (formatstr % int1)
    if len(hexstr) % 2 == 1: hexstr = '0' + hexstr
    return hexstr.decode('hex')