[git] GPGME - branch, ben/docs/2018-03, updated. gpgme-1.10.0-128-gac6a552

by Ben McGinnes cvs at cvs.gnupg.org
Wed Mar 21 15:32:16 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, ben/docs/2018-03 has been updated
       via  ac6a552c37147a000de74f49d1bff34dad52252e (commit)
       via  af6cbba18ba5e2bbecce5f8268c146282cd12367 (commit)
       via  6fa2a344282e369e6aca8155bc77dd2c12a29414 (commit)
      from  1fdd1f306d45f6aeee91c7f016f7c37286ee3b3b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ac6a552c37147a000de74f49d1bff34dad52252e
Author: Ben McGinnes <ben at adversary.org>
Date:   Thu Mar 22 01:30:32 2018 +1100

    example: detach sign file
    
    * Added example to make detached signatures of a file with key selection.

diff --git a/lang/python/examples/howto/detach-sign-file.py b/lang/python/examples/howto/detach-sign-file.py
new file mode 100755
index 0000000..99fbe65
--- /dev/null
+++ b/lang/python/examples/howto/detach-sign-file.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from __future__ import absolute_import, division, unicode_literals
+
+# Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License and the GNU
+# Lesser General Public Licensefor more details.
+#
+# You should have received a copy of the GNU General Public License and the GNU
+# Lesser General Public along with this program; if not, see
+# <http://www.gnu.org/licenses/>.
+
+import gpg
+import sys
+
+"""
+Signs a file with a specified key.  If entering both the key and the filename
+on the command line, the key must be entered first.
+
+Will produce both an ASCII armoured and GPG binary format copy of the detached
+signature file.
+"""
+
+if len(sys.argv) > 3:
+    logrus = sys.argv[1]
+    filename = " ".join(sys.argv[2:])
+elif len(sys.argv) == 3:
+    logrus = sys.argv[1]
+    filename = sys.argv[2]
+elif len(sys.argv) == 2:
+    logrus = sys.argv[1]
+    filename = input("Enter the path and filename to sign: ")
+else:
+    logrus = input("Enter the fingerprint or key ID to sign with: ")
+    filename = input("Enter the path and filename to sign: ")
+
+with open(filename, "rb") as f:
+    text = f.read()
+
+key = list(gpg.Context().keylist(pattern=logrus))
+
+with gpg.Context(armor=True, signers=key) as ca:
+    signed_data, result = ca.sign(text, mode=gpg.constants.sig.mode.DETACH)
+    with open("{0}.asc".format(filename), "wb") as fa:
+        fa.write(signed_data)
+
+with gpg.Context(signers=key) as cb:
+    signed_data, result = cb.sign(text, mode=gpg.constants.sig.mode.DETACH)
+    with open("{0}.sig".format(filename), "wb") as fb:
+        fb.write(signed_data)

commit af6cbba18ba5e2bbecce5f8268c146282cd12367
Author: Ben McGinnes <ben at adversary.org>
Date:   Thu Mar 22 01:26:43 2018 +1100

    example: encrypt-sign-file.py
    
    * Adjusted the doc string.

diff --git a/lang/python/examples/howto/encrypt-sign-file.py b/lang/python/examples/howto/encrypt-sign-file.py
index c8850b2..4b29b27 100755
--- a/lang/python/examples/howto/encrypt-sign-file.py
+++ b/lang/python/examples/howto/encrypt-sign-file.py
@@ -34,8 +34,8 @@ filename on the command line, the key must be entered first.
 Signs with and also encrypts to the default key of the user invoking the
 script.  Will treat all recipients as trusted to permit encryption.
 
-Will produce both an ASCII armoured and GPG binary format copy of the encrypted
-file.
+Will produce both an ASCII armoured and GPG binary format copy of the signed
+and encrypted file.
 """
 
 if len(sys.argv) > 3:

commit 6fa2a344282e369e6aca8155bc77dd2c12a29414
Author: Ben McGinnes <ben at adversary.org>
Date:   Thu Mar 22 01:24:52 2018 +1100

    examples: doc strings
    
    * Fixed minor errors in two doc strings.

diff --git a/lang/python/examples/howto/encrypt-file.py b/lang/python/examples/howto/encrypt-file.py
index 017a342..877226d 100755
--- a/lang/python/examples/howto/encrypt-file.py
+++ b/lang/python/examples/howto/encrypt-file.py
@@ -31,7 +31,8 @@ import sys
 Encrypts a file to a specified key.  If entering both the key and the filename
 on the command line, the key must be entered first.
 
-Will produce both an ASCII armoured and GPG binary format copy of the encrypted file.
+Will produce both an ASCII armoured and GPG binary format copy of the encrypted
+file.
 """
 
 if len(sys.argv) > 3:
diff --git a/lang/python/examples/howto/sign-file.py b/lang/python/examples/howto/sign-file.py
index 8e2cdc2..01006df 100755
--- a/lang/python/examples/howto/sign-file.py
+++ b/lang/python/examples/howto/sign-file.py
@@ -31,7 +31,8 @@ import sys
 Signs a file with a specified key.  If entering both the key and the filename
 on the command line, the key must be entered first.
 
-Will produce both an ASCII armoured and GPG binary format copy of the encrypted file.
+Will produce both an ASCII armoured and GPG binary format copy of the signed
+file.
 """
 
 if len(sys.argv) > 3:

-----------------------------------------------------------------------

Summary of changes:
 .../examples/howto/{sign-file.py => detach-sign-file.py}    | 13 +++++++------
 lang/python/examples/howto/encrypt-file.py                  |  3 ++-
 lang/python/examples/howto/encrypt-sign-file.py             |  4 ++--
 lang/python/examples/howto/sign-file.py                     |  3 ++-
 4 files changed, 13 insertions(+), 10 deletions(-)
 copy lang/python/examples/howto/{sign-file.py => detach-sign-file.py} (89%)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list