16c2256a523d94fb746a970680dcacaeae298979
[platform/upstream/gpgme.git] / lang / python / examples / sign.py
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2016 g10 Code GmbH
4 # Copyright (C) 2002 John Goerzen <jgoerzen@complete.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import sys
23 import gpg
24 from gpg.constants.sig import mode
25
26 with gpg.Context() as c:
27     signed, _ = c.sign(b"Test message", mode=mode.CLEAR)
28     sys.stdout.buffer.write(signed)