Skip to content

Text Random

Random text generation utilities.

Modules

random_alphanumeric

Random Alphanumeric Generator

Generate random alphanumeric strings.

Functions

random_alphanumeric(length: int = 16, include_lowercase: bool = True, include_uppercase: bool = True) -> str

Generate a random alphanumeric string.

Parameters:

Name Type Description Default
length int

Length of the random string

16
include_lowercase bool

Include lowercase letters

True
include_uppercase bool

Include uppercase letters

True

Returns:

Type Description
str

Random alphanumeric string

Raises:

Type Description
ValueError

If both include_lowercase and include_uppercase are False

Example

len(random_alphanumeric(10)) 10

random_hex

Random Hexadecimal Generator

Generate random hexadecimal strings.

Functions

random_hex(length: int = 16, uppercase: bool = False) -> str

Generate a random hexadecimal string.

Parameters:

Name Type Description Default
length int

Length of the random hex string

16
uppercase bool

Use uppercase letters for hex digits

False

Returns:

Type Description
str

Random hexadecimal string

Example

len(random_hex(10)) 10

random_string

Random String Generator

Generate secure random strings.

Functions

random_string(length: int = 16, charset: str = string.ascii_letters + string.digits) -> str

Generate a secure random string.

Parameters:

Name Type Description Default
length int

Length of the random string

16
charset str

Character set to use for generation

ascii_letters + digits

Returns:

Type Description
str

Secure random string

Example

len(random_string(20)) 20

options: show_root_heading: true show_source: false heading_level: 2