Created
April 1, 2019 01:23
-
-
Save indera-shsp/d07db94b9f5fd2dcc80bd34724ae2f44 to your computer and use it in GitHub Desktop.
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
| def hexlify(val): | |
| """ | |
| Note: | |
| - Without the decode() the builtin `hexlify` return the bytes for | |
| hexadecimal representation of the binary data. | |
| - The returned string is twice as long as the length of data. | |
| :param val: binary | |
| :rtype: string | |
| """ | |
| return binascii.hexlify(val).decode() | |
| def get_uuid_bin(): | |
| """ | |
| Note: the returned value needs to be hexlified to be human readable | |
| """ | |
| uuid_text = uuid.uuid1() | |
| return binascii.unhexlify(str(uuid_text).replace('-', '').lower().encode()) | |
| def get_uuid(): | |
| """ Generate a PK-friendly uuid""" | |
| val = str(uuid.uuid1()) | |
| return sort_uuid(val) | |
| def sort_uuid(val): | |
| return val[14:18] + val[9:13] + val[0:8] + val[19:23] + val[24:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment