Files
Dorod-Sky/skyvern/utils/strings.py

21 lines
436 B
Python
Raw Normal View History

import os
import random
import string
2026-01-22 01:42:42 +08:00
import uuid
RANDOM_STRING_POOL = string.ascii_letters + string.digits
def generate_random_string(length: int = 5) -> str:
# Use the os.urandom(16) as the seed
random.seed(os.urandom(16))
return "".join(random.choices(RANDOM_STRING_POOL, k=length))
2026-01-22 01:42:42 +08:00
def is_uuid(string: str) -> bool:
try:
uuid.UUID(string)
return True
except ValueError:
return False