rstr is a Python helper module designed for easily generating random strings of various types. It is suitable for applications such as fuzz testing, generating dummy data, or creating random values based on regular expressions. The library is currently at version 3.2.2 and is actively maintained.
pip install rstrVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic random string generation, fixed-length generation, regex-based generation with `xeger`, and how to use a cryptographically secure random number generator.
For sensitive applications, initialize `Rstr` with `random.SystemRandom()`: `from rstr import Rstr; from random import SystemRandom; secure_rstr = Rstr(SystemRandom())`.
Simplify regex patterns where possible, or consider using `star_plus_limit` argument of `Xeger` class to control repetition bounds more strictly for performance-critical scenarios. Profile performance with your specific patterns..
You can explicitly set the `star_plus_limit` when creating an `Xeger` instance to change this upper bound: `xeger_instance = Xeger(star_plus_limit=200); xeger_instance.xeger(r'a*')`..
Ensure your project runs on Python 3.7 or newer. If Python 2.x compatibility is required, you must use an older `rstr` version (e.g., <3.0.0), which is not recommended due to lack of maintenance..
Install the library using pip: `pip install rstr`
Provide a string value for the 'pattern' argument, for example: `rstr.rstr('abc')` or `rstr.rstr('hello', 5)`.Use the correct function names provided by the library, such as `rstr.rstr()` for random strings or `rstr.xeger()` for regex-based generation.
Correct the syntax of the regular expression pattern, for example, ensure all parentheses are matched or character ranges are valid. Example: `rstr.xeger('[a-z]{3}')`No dependency data recorded yet.