예제 #1
0
파일: profile.py 프로젝트: fason/stigmergy
    def refresh_dropped_signal(self):
        """
        Encrypt "DROPPED" to own and all dropped friends' keys.
        The purpose of this is that when a user logs in he can distinguish
        between friends who have not decrypted their profile for him 
        and friends who have dropped him.
        """
        dropped_keys = [self.keyfp]
        for fid in self.friend_id_list("former"):
            fprint = key_fingerprint(fid)
            if fprint is not None:
                dropped_keys.append(fprint)

        for fid in self.friend_id_list("extra_dropped_msg"):
            fprint = key_fingerprint(fid)
            if fprint is not None:
                dropped_keys.append(fprint)

        if settings.VERBOSE:
            print "########"
            print "Encrypting 'DROPPED' message to keys %s. data:\n %s" \
                % (str(dropped_keys), settings.DROPPED_CONTENT)

        data = msg_encrypt(settings.DROPPED_CONTENT, dropped_keys, hidden=True)
        self.dropped_signal = data
        if settings.VERBOSE:
            print "Encrypted data:\n %s\n\n\n\n" % self.dropped_signal
예제 #2
0
파일: profile.py 프로젝트: fason/stigmergy
    def encrypt(self, container="", data="", keys=[]):
        """
        Takes as argument the container to encrypt to and the data that should
        be a json string, encrypts it with keys and stores the encrypted data
        into container_data.
        """
        if settings.VERBOSE:
            print "########"
            print "Encrypting to container %s data:\n %s" % (container, data)

        data = msg_encrypt(str(data), keys, hidden=True)
        setattr(self, container+"_data", data)
        if settings.VERBOSE:
            print "Encrypted data:\n %s\n\n\n\n" \
                % (getattr(self, container+"_data", "") )