mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
11 lines
343 B
Python
11 lines
343 B
Python
import base64
|
|
import uuid as _uuid
|
|
|
|
|
|
def to_urluuid(uuid: _uuid.UUID) -> str:
|
|
"""Return a base64 url-friendly short UUID."""
|
|
return str(base64.urlsafe_b64encode(uuid.bytes), encoding="ascii").rstrip("=")
|
|
|
|
|
|
def from_urluuid(b: str) -> _uuid.UUID:
|
|
return _uuid.UUID(bytes=base64.urlsafe_b64decode(bytes(b + "==", encoding="ascii")))
|