From 172baaf4d3e4ed03a4d3437be9efa3dfe6a847bc Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Fri, 9 Mar 2018 20:45:14 +1100 Subject: [PATCH] doc: python bindings HOWTO * Added instructions and code to count the number of public and secret keys available since it was quick and easy. --- lang/python/docs/GPGMEpythonHOWTOen.org | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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