import base64


def get_vm_hash(dg_vm):
    """
    Returns a hash of a VM's state.
    
    :param dg_vm: A Digirule object
    :type: dgtools.Digirule
    :returns: A hash that is derived by all variables that contribute to the VM's state.
    :rtype: int
    """
    hash_obj = list(dg_vm._mem)
    hash_obj.extend([dg_vm._acc,
                     dg_vm._pc,
                     dg_vm._mem[252], 
                     dg_vm._mem[253], 
                     dg_vm._mem[254], 
                     dg_vm._mem[255]])
    hash_obj.extend(dg_vm._ppc)
    return hash(base64.b64encode(bytearray(hash_obj)))