FitTrackee/fittrackee/workouts/utils/short_id.py

18 lines
318 B
Python
Raw Normal View History

2021-01-02 19:28:03 +01:00
from uuid import UUID
2020-12-30 22:07:43 +01:00
import shortuuid
2021-01-02 19:28:03 +01:00
def encode_uuid(uuid_value: UUID) -> str:
"""
2022-02-16 17:46:22 +01:00
Return short id string from a UUID
2021-01-02 19:28:03 +01:00
"""
2020-12-30 22:07:43 +01:00
return shortuuid.encode(uuid_value)
2021-01-02 19:28:03 +01:00
def decode_short_id(short_id: str) -> UUID:
"""
Return UUID from a short id string
"""
2020-12-30 22:07:43 +01:00
return shortuuid.decode(short_id)