Пример #1
0
def decrypt_gpg(lines, fd):
    for line in fd:
        lines.append(line)
        if line.startswith(GPG_END_MESSAGE):
            break

    gpg = GnuPG()
    _, encryption_info, plaintext = gpg.decrypt(''.join(lines))

    if encryption_info['status'] != 'decrypted':
        gpg_exec = distutils.spawn.find_executable('gpg')
        gpg_version = gpg.version()
        raise AccessError("GPG (version: %s, location: %s) was unable to decrypt the data: %s" % (gpg_version, gpg_exec, encryption_info['status']))

    return plaintext.splitlines(True)