From 920ba331bd5c11f54231c8a57fe88a5af9755725 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 --- __init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to '__init__.py') diff --git a/__init__.py b/__init__.py index 3d685635..94286370 100644 --- a/__init__.py +++ b/__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