Generate a random string of fixed length
(length=10, include_digits=False)
| 39 | |
| 40 | |
| 41 | def random_string(length=10, include_digits=False): |
| 42 | """Generate a random string of fixed length""" |
| 43 | letters = string.ascii_lowercase |
| 44 | if include_digits: |
| 45 | letters += string.digits |
| 46 | |
| 47 | return "".join(secrets.choice(letters) for _ in range(length)) |
| 48 | |
| 49 | |
| 50 | _ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." |
no outgoing calls