2025-12-04 10:09:04 +08:00

22 lines
668 B
Python

# generators.py
import random
import string
from datetime import datetime
PASSWORD_LENGTH = 16
SPECIAL_CHARS = "0~!@#$%^&*-_+=|:;<>.,?/"
ALL_CHARS = string.ascii_letters + string.digits + SPECIAL_CHARS
def generate_password():
while True:
password = ''.join(random.choices(ALL_CHARS, k=PASSWORD_LENGTH))
if (any(c.islower() for c in password) and
any(c.isupper() for c in password) and
any(c.isdigit() for c in password) and
any(c in SPECIAL_CHARS for c in password)):
return password
def generate_instance_name(customer: str) -> str:
return f"{customer}-{datetime.now().strftime('%Y%m%d')}"