From d589dc008201bc0584a31ff36cbfafb29c01b574 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Mon, 19 Aug 2013 11:47:25 +0200 Subject: Add more docstring on okupy.common and okupy.otp. --- okupy/common/crypto.py | 5 +++++ okupy/common/models.py | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'okupy/common') diff --git a/okupy/common/crypto.py b/okupy/common/crypto.py index 57694c0..2596680 100644 --- a/okupy/common/crypto.py +++ b/okupy/common/crypto.py @@ -51,6 +51,11 @@ cipher = OkupyCipher() class IDCipher(object): + """ + A cipher to create 'encrypted database IDs'. It is specifically fit + to encrypt an integer into constant-length hexstring. + """ + def encrypt(self, id): byte_id = struct.pack('!I', id) byte_eid = cipher.encrypt(byte_id) diff --git a/okupy/common/models.py b/okupy/common/models.py index d1ef128..4a7ee73 100644 --- a/okupy/common/models.py +++ b/okupy/common/models.py @@ -17,10 +17,17 @@ class EncryptedPKModelManager(models.Manager): class EncryptedPKModel(models.Model): + """ + A model with built-in identifier encryption (for secure tokens). + """ + objects = EncryptedPKModelManager() @property def encrypted_id(self): + """ + The object identifier encrypted using IDCipher, as a hex-string. + """ if self.id is None: return None return idcipher.encrypt(self.id) -- cgit v1.2.3-65-gdbad