Created
September 5, 2013 07:41
-
-
Save sunliwen/6447111 to your computer and use it in GitHub Desktop.
uuid and shortuuid in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `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