You've already forked hotpocket
This commit is contained in:
14
services/packages/common/hotpocket_common/uuid.py
Normal file
14
services/packages/common/hotpocket_common/uuid.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import secrets
|
||||
|
||||
from uuid6 import UUID
|
||||
|
||||
|
||||
def uuid7_from_timestamp(timestamp: int) -> UUID:
|
||||
# The code below was shamelessly taken from `uuid6-python` package.
|
||||
# Copyright (c) 2021 oittaa | MIT License
|
||||
uuid_int = ((timestamp * 1_000) & 0xFFFFFFFFFFFF) << 80
|
||||
uuid_int |= secrets.randbits(76)
|
||||
return UUID(int=uuid_int, version=7)
|
||||
Reference in New Issue
Block a user