aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-08-21 01:22:52 +0200
committerMichał Górny <mgorny@gentoo.org>2013-08-21 01:27:47 +0200
commit9e33b391e120f0684cba2768613c1199c2596e3b (patch)
treede0925e1afd1132932a4faded95a9d76e8fc5e4c /okupy/common
parentEncode encrypted session ID using base32. (diff)
downloadidentity.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.py5
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