diff options
| author | Cody Logan <clpo13@gmail.com> | 2020-08-05 17:21:45 -0700 |
|---|---|---|
| committer | Cody Logan <clpo13@gmail.com> | 2020-08-05 17:22:41 -0700 |
| commit | 52e72221bf65d118bc323866243f3fdbd2589c58 (patch) | |
| tree | 52eda1955e56b2323b6988819cbf4dbc9a3e9136 /alphanum/alphanum.py | |
| parent | e06712a3618f095dc47df9a39da63f4e916ec35a (diff) | |
| download | alphanum-52e72221bf65d118bc323866243f3fdbd2589c58.tar.gz alphanum-52e72221bf65d118bc323866243f3fdbd2589c58.zip | |
Initialize gh-pages
Diffstat (limited to 'alphanum/alphanum.py')
| -rw-r--r-- | alphanum/alphanum.py | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/alphanum/alphanum.py b/alphanum/alphanum.py deleted file mode 100644 index 3f16d3c..0000000 --- a/alphanum/alphanum.py +++ /dev/null @@ -1,31 +0,0 @@ -try: - import secrets as random -except ImportError: - import random -import string - -POP = string.ascii_letters + string.digits - - -def generate(length: int = 1) -> str: - """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 - :py:mod:`random`. With 3.6 and later, the randomness is generated with - :py:mod:`secrets`, making the randomization cryptographically strong. - - Args: - length (:obj:`int`, optional): Desired string length. Defaults to 1. - - Returns: - str: A pseudo-random alphanumeric string. - - Examples: - >>> print(alphanum.generate()) - 'G' - >>> print(alphanum.generate(10)) - 'a93jfDjdA0' - - """ - return ''.join(random.SystemRandom().choice(POP) for i in range(length)) |
