alphanum package

Submodules

alphanum.alphanum module

alphanum.alphanum.generate(length: int = 1)str[source]

Generates a random string of alphanumeric characters of the given length. If no length is specified, a single character is returned.

On Python 3.5, this string is pseudo-randomly generated using random. With 3.6 and later, the randomness is generated with secrets, making the randomization cryptographically strong.

Parameters

length (int, optional) – Desired string length. Defaults to 1.

Returns

A pseudo-random alphanumeric string.

Return type

str

Examples

>>> print(alphanum.generate())
'G'
>>> print(alphanum.generate(10))
'a93jfDjdA0'

Module contents