11 lines
234 B
Python
11 lines
234 B
Python
|
|
import secrets
|
||
|
|
import string
|
||
|
|
|
||
|
|
def generate_secure_string(length):
|
||
|
|
if length <= 0:
|
||
|
|
return ""
|
||
|
|
|
||
|
|
characters = string.ascii_letters + string.digits
|
||
|
|
return ''.join(secrets.choice(characters) for _ in range(length))
|
||
|
|
|