From 8febf0c6f71395bbc8a24440beb28dfb719ba01c Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 3 Dec 2012 10:32:54 -0200 Subject: Add LeapDocument methods for encrypting/decrypting --- src/leap/soledad/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py index 3d685635..94286370 100644 --- a/src/leap/soledad/__init__.py +++ b/src/leap/soledad/__init__.py @@ -16,6 +16,7 @@ from u1db import ( ) from swiftclient import client +import base64 class OpenStackDatabase(CommonBackend): @@ -148,10 +149,20 @@ class OpenStackDatabase(CommonBackend): class LeapDocument(Document): def get_content_encrypted(self): - raise NotImplementedError(self.get_content_encrypted) + """ + Returns document's json serialization encrypted with user's public key. + """ + # TODO: replace for openpgp encryption with users's pub key. + return base64.b64encode(self.get_json()) def set_content_encrypted(self): - raise NotImplementedError(self.set_content_encrypted) + """ + Set document's content based on encrypted version of json string. + """ + # TODO: + # - replace for openpgp decryption using user's priv key. + # - raise error if unsuccessful. + return self.set_json(base64.b64decode(self.get_json())) class OpenStackSyncTarget(CommonSyncTarget): -- cgit v1.2.3