diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-08-19 11:47:25 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-08-19 13:59:46 +0200 |
commit | d589dc008201bc0584a31ff36cbfafb29c01b574 (patch) | |
tree | bf930c43cfd76d0d175f267139c7a54aa3099d21 /okupy/common | |
parent | login: ask only for password when upgrading auth. (diff) | |
download | identity.gentoo.org-d589dc008201bc0584a31ff36cbfafb29c01b574.tar.gz identity.gentoo.org-d589dc008201bc0584a31ff36cbfafb29c01b574.tar.bz2 identity.gentoo.org-d589dc008201bc0584a31ff36cbfafb29c01b574.zip |
Add more docstring on okupy.common and okupy.otp.
Diffstat (limited to 'okupy/common')
-rw-r--r-- | okupy/common/crypto.py | 5 | ||||
-rw-r--r-- | okupy/common/models.py | 7 |
2 files changed, 12 insertions, 0 deletions
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) |