diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-08-21 01:22:52 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-08-21 01:27:47 +0200 |
commit | 9e33b391e120f0684cba2768613c1199c2596e3b (patch) | |
tree | de0925e1afd1132932a4faded95a9d76e8fc5e4c /okupy/common | |
parent | Encode encrypted session ID using base32. (diff) | |
download | identity.gentoo.org-9e33b391e120f0684cba2768613c1199c2596e3b.tar.gz identity.gentoo.org-9e33b391e120f0684cba2768613c1199c2596e3b.tar.bz2 identity.gentoo.org-9e33b391e120f0684cba2768613c1199c2596e3b.zip |
IDCipher: use unpadded base32 as well.
Diffstat (limited to 'okupy/common')
-rw-r--r-- | okupy/common/crypto.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/okupy/common/crypto.py b/okupy/common/crypto.py index 1fdcf7c..2517276 100644 --- a/okupy/common/crypto.py +++ b/okupy/common/crypto.py @@ -9,7 +9,6 @@ from Crypto.Hash.SHA384 import SHA384Hash import Crypto.Random import base64 -import binascii import struct @@ -78,10 +77,10 @@ class IDCipher(object): def encrypt(self, id): byte_id = struct.pack('!I', id) byte_eid = cipher.encrypt(byte_id) - return binascii.b2a_hex(byte_eid) + return ub32encode(byte_eid).lower() def decrypt(self, eid): - byte_eid = binascii.a2b_hex(eid) + byte_eid = ub32decode(eid) byte_id = cipher.decrypt(byte_eid, 4) id = struct.unpack('!I', byte_id)[0] return id |