Files
python_skripte/create_ps/create_ps.py
jonnybravo a692ac8b05
All checks were successful
test / build-docs (push) Successful in -19s
current
2025-07-10 21:03:06 +02:00

33 lines
802 B
Python
Executable File

#! /usr/bin/env python
import string
import secrets
def create_password(long=int(10), sonder="!#$%&()*+-/:;<=>?@[]_{|}"):
print("Sonderzeichen:", sonder)
alle = string.ascii_letters + string.digits + sonder
while True:
tx = ""
anz = [0, 0, 0, 0]
for i in range(long):
zeichen = secrets.choice(alle)
tx += zeichen
if zeichen in string.ascii_lowercase:
anz[0] += 1
elif zeichen in string.ascii_uppercase:
anz[1] += 1
elif zeichen in string.digits:
anz[2] += 1
else:
anz[3] += 1
# print("Anzahl:", anz)
if 0 not in anz:
break
return tx
if __name__ == "__main__":
print(create_password(long=20))