Commit c7ab4b4d authored by anthraxx's avatar anthraxx
Browse files

reduce uid range by one byte for checksum

parent c57452b9
......@@ -18,12 +18,12 @@ class TokenGenerator(object):
def make_barcode(self):
while True:
id = randrange(9000000000, 9999999999)
id = randrange(900000000, 999999999)
if not self.db.get(Customer, id=id):
self.db.get_or_create(Customer, id=id)
ean = EAN13("{}{}".format(Logic.USER_ID_PREFIX, str(id).zfill(10)))
ean = EAN13("{}{}".format(Logic.USER_ID_PREFIX, str(id).zfill(9)))
f = BytesIO()
ean.write(f, {'write_text': False})
return base64.encodestring(f.getvalue()).decode('utf-8')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment