Skip to content

Instantly share code, notes, and snippets.

@christ0pher
Created November 29, 2016 11:17
Show Gist options
  • Save christ0pher/3d0cbba0c8baf35eebcacdbf3c9128ce to your computer and use it in GitHub Desktop.
Save christ0pher/3d0cbba0c8baf35eebcacdbf3c9128ce to your computer and use it in GitHub Desktop.
import base64
import uuid
__author__ = 'wolf@youpooly.com'
def enc_uuid(uid):
uuid_uid = uuid.UUID(uid)
uuid_uid_bytes = uuid_uid.bytes
uuid_uid_bytes_64 = base64.urlsafe_b64encode(uuid_uid_bytes)
return uuid_uid_bytes_64.decode()
def dec_uuid(uid):
uuid_uid_bytes_64 = base64.urlsafe_b64decode(uid)
uuid_dec = uuid.UUID(bytes=uuid_uid_bytes_64)
return str(uuid_dec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment