Skip to main content

get_random_string

Return a securely generated random string.

def get_random_string(
length: int,
allowed_chars: string = RANDOM_STRING_CHARS
) - > string

Return a securely generated random string.

Parameters

NameTypeDescription
lengthintThe number of characters to include in the generated string. Each character increases the total entropy (bit length) of the result.
allowed_charsstring = RANDOM_STRING_CHARSA sequence of characters to sample from when building the random string. Defaults to a set of alphanumeric characters.

Returns

TypeDescription
stringA cryptographically secure random string composed of characters from the allowed set.