Skip to content

Commit

Permalink
chore: Move crypto_random_object_id to shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jkuzz committed Dec 5, 2024
1 parent b6ee7a7 commit 6e8e51c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/apify_shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io
import json
import re
import secrets
from datetime import datetime, timezone
from enum import Enum
from typing import Any, TypeVar, cast
Expand Down Expand Up @@ -115,3 +116,9 @@ def parse(key: str, value: object) -> object:
return {key: parse(key, value) for (key, value) in data.items()}

return data

@ignore_docs
def crypto_random_object_id(length: int = 17) -> str:
"""Generates a random object ID."""
chars = 'abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ0123456789'
return ''.join(secrets.choice(chars) for _ in range(length))

0 comments on commit 6e8e51c

Please sign in to comment.