aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/examples/howto/advanced/cython/keycount.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'lang/python/examples/howto/advanced/cython/keycount.pyx')
-rwxr-xr-xlang/python/examples/howto/advanced/cython/keycount.pyx16
1 files changed, 16 insertions, 0 deletions
diff --git a/lang/python/examples/howto/advanced/cython/keycount.pyx b/lang/python/examples/howto/advanced/cython/keycount.pyx
new file mode 100755
index 00000000..f0097db2
--- /dev/null
+++ b/lang/python/examples/howto/advanced/cython/keycount.pyx
@@ -0,0 +1,16 @@
+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))