From aeb1e6057804a815b216a44979150e3f28ef2a5e Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 18 Apr 2016 23:48:17 -0700 Subject: [bug] encryption keys can now be serialized to json using key.get_dict() --- keymanager/changes/bug-serializable-keys | 1 + keymanager/src/leap/keymanager/keys.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 keymanager/changes/bug-serializable-keys diff --git a/keymanager/changes/bug-serializable-keys b/keymanager/changes/bug-serializable-keys new file mode 100644 index 0000000..0885fd2 --- /dev/null +++ b/keymanager/changes/bug-serializable-keys @@ -0,0 +1 @@ +- encryption keys can now be serialized to json using key.get_dict() diff --git a/keymanager/src/leap/keymanager/keys.py b/keymanager/src/leap/keymanager/keys.py index 38d66b5..34d921c 100644 --- a/keymanager/src/leap/keymanager/keys.py +++ b/keymanager/src/leap/keymanager/keys.py @@ -258,6 +258,20 @@ class EncryptionKey(object): KEY_TAGS_KEY: [KEYMANAGER_ACTIVE_TAG], }) + def get_dict(self): + """ + :return: a serializable dict representation of this key. + :rtype: dict + """ + return { + KEY_ADDRESS_KEY: self.address, + KEY_UIDS_KEY: self.uids, + KEY_FINGERPRINT_KEY: self.fingerprint, + KEY_LENGTH_KEY: self.length, + KEY_EXPIRY_DATE_KEY: str(self.expiry_date), + KEY_DATA_KEY: self.key_data + } + def __repr__(self): """ Representation of this class -- cgit v1.2.3