summaryrefslogtreecommitdiff
path: root/alot/crypto.py
diff options
context:
space:
mode:
authorJohannes Kulick <kulick@hildensia.de>2012-12-15 13:34:48 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-02-19 10:10:07 +0000
commit6db4ecfb75ec1969426adbb154bbb3ccbded6b1a (patch)
tree7528d1793d3cd778175a468a8e9d12f40dcddd61 /alot/crypto.py
parent8448de9d8a81225ac43f625c4bd99358e4329546 (diff)
rmencrypt now accepts keyids/hints instead of indices
We use an own has function for that, since pygpgme doesn't implement __cmp__() or similar
Diffstat (limited to 'alot/crypto.py')
-rw-r--r--alot/crypto.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/alot/crypto.py b/alot/crypto.py
index be7e83e2..82b76ecb 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -171,3 +171,17 @@ def encrypt(plaintext_str, keys=None):
encrypted_data.seek(0, 0)
encrypted = encrypted_data.read()
return encrypted
+
+def hash_key(key):
+ """
+ Returns a hash of the given key. This is a workaround for
+ https://bugs.launchpad.net/pygpgme/+bug/1089865
+ and can be removed if the missing feature is added to pygpgme
+
+ :param key: the key we want a hash of
+ :rtype: a has of the key as string
+ """
+ hash_str = ""
+ for tmp_key in key.subkeys:
+ hash_str += tmp_key.keyid
+ return hash_str