aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/docs/GPGMEpythonHOWTOen.org
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-03-09 09:45:14 +0000
committerBen McGinnes <[email protected]>2018-03-09 09:45:14 +0000
commit172baaf4d3e4ed03a4d3437be9efa3dfe6a847bc (patch)
tree33b370ac5213e9667f5a725331d4d319fb168bd5 /lang/python/docs/GPGMEpythonHOWTOen.org
parentdoc: python TODO list (diff)
downloadgpgme-172baaf4d3e4ed03a4d3437be9efa3dfe6a847bc.tar.gz
gpgme-172baaf4d3e4ed03a4d3437be9efa3dfe6a847bc.zip
doc: python bindings HOWTO
* Added instructions and code to count the number of public and secret keys available since it was quick and easy.
Diffstat (limited to 'lang/python/docs/GPGMEpythonHOWTOen.org')
-rw-r--r--lang/python/docs/GPGMEpythonHOWTOen.org33
1 files changed, 33 insertions, 0 deletions
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 0b882b55..4385bc9b 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -498,6 +498,39 @@
#+end_src
+* Working with keys
+ :PROPERTIES:
+ :CUSTOM_ID: howto-keys
+ :END:
+
+** Counting keys
+ :PROPERTIES:
+ :CUSTOM_ID: howto-basic-verification
+ :END:
+
+ Counting the number of keys in your public keybox (=pubring.kbx=),
+ the format shich has superceded the old keyring format
+ (=pubring.gpg= and =secring.gpg=) is a very simple task.
+
+ #+begin_src python
+ import gpg
+
+ c = gpg.Context()
+ seckeys = c.keylist(pattern=None, secret=True)
+ pubkeys = c.keylist(pattern=None, secret=False)
+
+ seclist = list(seckeys)
+ secnum = len(seclist)
+
+ publist = list(pubkeys)
+ pubnum = len(publist)
+
+ print("""
+ Number of secret keys: {0}
+ Number of public keys: {1}
+ """.format(secnum, pubnum)
+ #+end_src
+
* Copyright and Licensing
:PROPERTIES:
:CUSTOM_ID: copyright-and-license