d2db326c70
Fork of LainsNL/OutlookRegister with OAuth hardening, optional recovery email, batching, and MIT license. Ships example config only (no local secrets).
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
import random
|
|
import string
|
|
import secrets
|
|
|
|
def random_email(length=None):
|
|
# 默认随机长度 11~17
|
|
if length is None:
|
|
length = random.randint(11, 17)
|
|
|
|
first_char = random.choice(string.ascii_lowercase)
|
|
|
|
other_chars = []
|
|
for _ in range(length - 1):
|
|
# 数字概率 10%
|
|
if random.random() < 0.1:
|
|
other_chars.append(random.choice(string.digits))
|
|
else:
|
|
other_chars.append(random.choice(string.ascii_lowercase))
|
|
|
|
return first_char + ''.join(other_chars)
|
|
|
|
def generate_strong_password(length=None):
|
|
if length is None:
|
|
length = random.randint(10, 14)
|
|
|
|
chars = string.ascii_letters + string.digits + "!@#$%^&*"
|
|
|
|
while True:
|
|
password = ''.join(secrets.choice(chars) for _ in range(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 "!@#$%^&*" for c in password)
|
|
):
|
|
return password
|