23 lines
547 B
Python
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
|