Random String - CrowdStrike/falconpy GitHub Wiki

CrowdStrike Falcon CrowdStrike Subreddit

Randomly generating a string

Documentation Version Page Updated

This helper provides developers with a simple function to randomly generate a string of letters, numbers, or characters.

The random_string function was first introduced in FalconPy v1.5.1.

Result example

Results are returned as a string, regardless of keyword arguments supplied.

lqp7iGsob0

Keyword arguments

This function supports four keyword arguments.

Keyword Data type Default Allowed values
length Integer 10 Any

Performance will be impacted by generating extremely long strings
include_letters Boolean True True or False
include_digits Boolean True True or False
include_specials Boolean False True or False

Generating a random string

Calling the function without arguments will produce a 10 character long string of numbers and mixed-case letters similar to the result example above.

Keywords may be provided in any order and combination.

Code example

from falconpy import random_string
result = random_string()
print(result)

Output example

lqp7iGsob0

The length of the returned string can be specified using the length keyword argument.

Code example

from falconpy import random_string
result = random_string(length=25)
print(result)

Output example

LOtxDgHV9z0OblG1wOykSFgLm

Letters, numerical digits and special characters can be enabled and disabled using the include_letters, include_digits and include_specials keywords.

The following example will generate a string of 10 numbers.

Code example

from falconpy import random_string
result = random_string(include_letters=False)

Output example

The generated value is returned as a string.

6759739861

This example will generate a 25 character string, containing numbers, numerical digits and special characters.

Code example

from falconpy import random_string
result = random_string(length=25, include_specials=True)

Output example

0h&OLSUofllhtUwbZdwu@BymF
⚠️ **GitHub.com Fallback** ⚠️