Blame lang/python/examples/decryption-filter.py
|
Packit Service |
672cf4 |
#!/usr/bin/env python
|
|
Packit Service |
672cf4 |
#
|
|
Packit Service |
0ef63b |
# Copyright (C) 2016, 2018 g10 Code GmbH
|
|
Packit Service |
672cf4 |
#
|
|
Packit Service |
672cf4 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
672cf4 |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
672cf4 |
# the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
672cf4 |
# (at your option) any later version.
|
|
Packit Service |
672cf4 |
#
|
|
Packit Service |
672cf4 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit Service |
672cf4 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
672cf4 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
672cf4 |
# General Public License for more details.
|
|
Packit Service |
672cf4 |
#
|
|
Packit Service |
672cf4 |
# You should have received a copy of the GNU General Public License
|
|
Packit Service |
0ef63b |
# along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
Packit Service |
672cf4 |
"""A decryption filter
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
This demonstrates decryption using gpg in three lines of code. To
|
|
Packit Service |
672cf4 |
be used like this:
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
0ef63b |
./decryption-filter.py < message.gpg > message.plain
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
"""
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
from __future__ import absolute_import, print_function, unicode_literals
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
import sys
|
|
Packit Service |
672cf4 |
import gpg
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
0ef63b |
del absolute_import, print_function, unicode_literals
|
|
Packit Service |
0ef63b |
|
|
Packit Service |
672cf4 |
gpg.Context().decrypt(sys.stdin, sink=sys.stdout)
|