Skip to content

Instantly share code, notes, and snippets.

@sunliwen
Created September 5, 2013 07:41
Show Gist options
  • Save sunliwen/6447111 to your computer and use it in GitHub Desktop.
Save sunliwen/6447111 to your computer and use it in GitHub Desktop.
uuid and shortuuid in python
# `pip install shortuuid`
import uuid
long = uuid.uuid5(namespace=uuid.NAMESPACE_URL, name="http://example.com")
print long # UUID('8c9ddcb0-8084-5a7f-a988-1095ab18b5df')
import shortuuid
short = shortuuid.uuid(name="http://example.com")
print short # 'c8sh5y9hdSMS6zVnrvf53T'
print long == shortuuid.decode(short) # True
print short == shortuuid.encode(long) # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment