diff options
author | elijah <elijah@riseup.net> | 2016-04-18 23:48:17 -0700 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-04-19 12:16:23 -0400 |
commit | 4a532500e3a6130199a10622d17f10a247609f06 (patch) | |
tree | 5db35512d6ed62dd2fb55fdf450fa1cb7aede79a | |
parent | f2f497a75e831fa142d098ad67c89dde98d783ea (diff) |
[bug] encryption keys can now be serialized to json using key.get_dict()
-rw-r--r-- | changes/bug-serializable-keys | 1 | ||||
-rw-r--r-- | src/leap/keymanager/keys.py | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/changes/bug-serializable-keys b/changes/bug-serializable-keys new file mode 100644 index 0000000..0885fd2 --- /dev/null +++ b/changes/bug-serializable-keys @@ -0,0 +1 @@ +- encryption keys can now be serialized to json using key.get_dict() diff --git a/src/leap/keymanager/keys.py b/src/leap/keymanager/keys.py index 38d66b5..34d921c 100644 --- a/src/leap/keymanager/keys.py +++ b/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 |