'Note that this test will fail if you don\'t replace the recipient with
one whose key you control.
>>> g = GnuPG(None)
>>> ct = g.encrypt("Hello, World", to=["smari@mailpile.is"])[1]
>>> g.decrypt(ct)["text"]
\'Hello, World\''

def decrypt(self, data, outputfd=None, passphrase=None, as_lines=False):

    if (passphrase is not None):
        self.passphrase = passphrase.get_reader()
    elif GnuPG.LAST_KEY_USED:
        self.prepare_passphrase(GnuPG.LAST_KEY_USED, decrypting=True)
    self.event.running_gpg((_('Decrypting    %d    bytes    of    data') % len(data)))
    for tries in (1, 2):
        retvals = self.run(['--decrypt'], gpg_input=data, outputfd=outputfd, send_passphrase=True)
        if (retvals[0] == 0):
            break
        elif (tries == 1):
            keyid = None
            for msg in retvals[1]['status']:
                if ((msg[0] == 'NEED_PASSPHRASE') and (passphrase is None)):
                    if self.prepare_passphrase(msg[2], decrypting=True):
                        keyid = msg[2]
                        break
            if (not keyid):
                break
    if as_lines:
        as_lines = retvals[1]['stdout']
        retvals[1]['stdout'] = []
    rp = GnuPGResultParser().parse(retvals)
    return (rp.signature_info, rp.encryption_info, (as_lines or rp.plaintext))
