12345678910111213141516171819202122232425262728 |
- def uuid_str_to_int(uuid_str: str) -> int:
- """
- >>> uuid_str_to_int('613ea4ac-a4cf-4026-8e99-1904b2bb5cd0')
- 129260377989791042510121038559452028112
- >>> uuid_str_to_int('779d1046-d163-4b2b-8126-254f631cb6a5')
- 158993652234522396927268087548725737125
- """
- return int(uuid_str.replace('-', ''), 16)
- def uuid_int_to_bytes(uuid_siv: int) -> bytes:
- """
- >>> uuid_int_to_bytes(129260377989791042510121038559452028112)
- b'a>\\xa4\\xac\\xa4\\xcf@&\\x8e\\x99\\x19\\x04\\xb2\\xbb\\\\\\xd0'
- >>> uuid_int_to_bytes(158993652234522396927268087548725737125)
- b'w\\x9d\\x10F\\xd1cK+\\x81&%Oc\\x1c\\xb6\\xa5'
- """
- return uuid_siv.to_bytes(16, byteorder='big')
- def uuid_str_to_bytes(uuid_str: str) -> bytes:
- """
- >>> uuid_str_to_bytes('613ea4ac-a4cf-4026-8e99-1904b2bb5cd0')
- b'a>\\xa4\\xac\\xa4\\xcf@&\\x8e\\x99\\x19\\x04\\xb2\\xbb\\\\\\xd0'
- >>> uuid_str_to_bytes('779d1046-d163-4b2b-8126-254f631cb6a5')
- b'w\\x9d\\x10F\\xd1cK+\\x81&%Oc\\x1c\\xb6\\xa5'
- """
- return uuid_int_to_bytes(uuid_str_to_int(uuid_str))
|