def Bin2Hex(numstr):
    """Converts the given binary numstr (string) to a hex string. Returns the
    string.
    """
    result = ''
    while len(numstr):
        bstr = numstr[:8]
        numstr = numstr[8:]
        tmpval = 0
        for x in bstr:
            tmpval *= 2
            tmpval += int(x)
        result += '%x' % tmpval
    return result
