示例#1
0
    def encrypt_file(self, newfile):
        """Encrypt a string, to the gpg key of the specified recipient)"""

        # In order for this to work, we need to temporarily import B's key into A's keyring.
        # We then do the encryptions, and immediately remove it.
        recipient = Key(pub=encrypt_to)
        recipient._format_keys()
        self.gpg.import_keys(recipient.pubkey)

        tmpfilename = "tmp/gpgfiles/" + TavernUtils.longtime(
        ) + TavernUtils.randstr(50, printable=True)

        self.gpg.encrypt_file(stream=oldfile,
                              recipients=[recipient.fingerprint],
                              always_trust=True,
                              armor=True,
                              output=tmpfilename)
        self.gpg.delete_keys(recipient.fingerprint)
        return tmpfilename
示例#2
0
文件: key.py 项目: bitmonk/Tavern
    def encrypt_file(self, newfile):
        """Encrypt a string, to the gpg key of the specified recipient)"""

        # In order for this to work, we need to temporarily import B's key into A's keyring.
        # We then do the encryptions, and immediately remove it.
        recipient = Key(pub=encrypt_to)
        recipient._format_keys()
        self.gpg.import_keys(recipient.pubkey)

        tmpfilename = "tmp/gpgfiles/" + TavernUtils.longtime(
        ) + TavernUtils.randstr(50, printable=True)

        self.gpg.encrypt_file(
            stream=oldfile,
            recipients=[recipient.fingerprint],
            always_trust=True,
            armor=True,
            output=tmpfilename)
        self.gpg.delete_keys(recipient.fingerprint)
        return tmpfilename
示例#3
0
文件: key.py 项目: bitmonk/Tavern
    def decrypt_file(self, tmpfile):

        tmpfilename = "tmp/gpgfiles/" + TavernUtils.longtime(
        ) + TavernUtils.randstr(50, printable=True)
        self.gpg.decrypt_file(tmpfile, output=tmpfilename)
        return tmpfilename
示例#4
0
    def decrypt_file(self, tmpfile):

        tmpfilename = "tmp/gpgfiles/" + TavernUtils.longtime(
        ) + TavernUtils.randstr(50, printable=True)
        self.gpg.decrypt_file(tmpfile, output=tmpfilename)
        return tmpfilename