Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`python`.`randbytes`.`RandomFactory``

class documentation

`class RandomFactory: (source)`

View In Hierarchy

Factory providing `secureRandom` and `insecureRandom` methods.

You shouldn't have to instantiate this class, use the module level functions instead: it is an implementation detail and could be removed or changed arbitrarily.

Method | `insecureRandom` | Return a number of non secure random bytes.
Method | `secureRandom` | Return a number of secure random bytes.
Class Variable | `randomSources` | Undocumented
Method | `_osUrandom` | Wrapper around `os.urandom` that cleanly manage its absence.
Method | `_randBits` | Wrapper around `os.getrandbits`.
Method | `_randModule` | Wrapper around the `random` module.
Constant | `_BYTES` | Undocumented

def insecureRandom(self, nbytes: `int`) -> `bytes`: (source)

Return a number of non secure random bytes.

Parameters
nbytes:`int` | number of bytes to generate.
Returns
`str` | a string of random bytes.

def secureRandom(self, nbytes: `int`, fallback: `bool` = False) -> `bytes`: (source)

Return a number of secure random bytes.

Parameters
nbytes:`int` | number of bytes to generate.
fallback:`bool` | Whether the function should fallback on non-secure random or not. Default to `False`.
Returns
`str` | a string of random bytes.

randomSources: `tuple` = (source)

Undocumented

def _osUrandom(self, nbytes: `int`) -> `bytes`: (source)

Wrapper around `os.urandom` that cleanly manage its absence.

def _randBits(self, nbytes: `int`) -> `bytes`: (source)

Wrapper around `os.getrandbits`.

def _randModule(self, nbytes: `int`) -> `bytes`: (source)

Wrapper around the `random` module.

_BYTES = (source)

Undocumented

Value

    _maketrans(b'', b'')