Skip to content

Instantly share code, notes, and snippets.

View qooba's full-sized avatar

Kuba Sołtys qooba

View GitHub Profile
@qooba
qooba / uuid_url64.py
Created April 21, 2018 21:20 — forked from mattupstate/uuid_url64.py
Generate unique, URL friendly ID's based on UUID with Python
import re
import uuid
import base64
def uuid_url64():
"""Returns a unique, 16 byte, URL safe ID by combining UUID and Base64
"""
rv = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
return re.sub(r'[\=\+\/]', lambda m: {'+': '-', '/': '_', '=': ''}[m.group(0)], rv)