import binascii


def weight(node, key):
    """Return the weight for the key on node.
    Uses the weighing algorithm as prescibed in the original HRW white paper.
    @params:
        node : 32 bit signed int representing IP of the node.
        key : string to be hashed.
    """
    a = 1103515245
    b = 12345
    _hash = binascii.crc32(key)
    return (a * ((a * node + b) ^ _hash) + b) % (2 ^ 31)