konova/kspneo/utils/generators.py
2021-07-01 13:36:07 +02:00

23 lines
547 B
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 09.11.20
"""
import random
import string
def generate_random_string(length: int, only_numbers: bool = False) -> str:
"""
Generates a random string of variable length
"""
if only_numbers:
elements = string.digits
else:
elements = string.ascii_letters
ret_val = "".join(random.choice(elements) for i in range(length))
return ret_val