Skip to content

Commit

Permalink
Merge pull request #1 from i0Ek3/dev_20240218
Browse files Browse the repository at this point in the history
add gen3/gen4
  • Loading branch information
i0Ek3 authored Apr 28, 2024
2 parents f75686c + 8bd3542 commit 7afa8b1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
37 changes: 33 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

app = Flask(__name__)


# 生成10-12位字母+数字+特殊字符
def genpwd(length):
characters = string.ascii_letters + string.digits + "!@#$%&*-"
password = random.choice(
Expand All @@ -16,7 +16,7 @@ def genpwd(length):
) # 确保密码不以特殊字符结尾
return password


# 生成10-12位字母+数字
def genpwd2():
password = ""
for _ in range(3):
Expand All @@ -27,12 +27,41 @@ def genpwd2():
password = password[:-1] # 移除末尾的连接符-
return password

# 生成10-12位纯数字
def genpwd3():
password = ""
for _ in range(3):
segment = "".join(
random.choice(string.digits) for _ in range(4)
)
password += segment
password = password[:-1] # 移除末尾的连接符-
return password

# 生成10-12位纯字母
def genpwd4():
password = ""
for _ in range(3):
segment = "".join(
random.choice(string.ascii_letters) for _ in range(4)
)
password += segment
password = password[:-1] # 移除末尾的连接符-
return password


@app.route("/", methods=["GET", "POST"])
def home():
if request.method == "POST":
pwda, pwdb = genpwd2(), genpwd(random.randint(8, 12))
return render_template("index.html", password=pwda, password2=pwdb)
pwda = genpwd2()
pwdb = genpwd(random.randint(10, 12))
pwdc = genpwd3()
pwdd = genpwd4()
return render_template("index.html",
password=pwda,
password2=pwdb,
password3=pwdc,
password4=pwdd)
return render_template("index.html")


Expand Down
7 changes: 7 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,12 @@
{% if password2 %}
<p>{{ password2 }}</p>
{% endif %}
{% if password3 %}
<p>{{ password3 }}</p>
{% endif %}
{% if password4 %}
<p>{{ password4 }}</p>
{% endif %}

</body>
</html>

0 comments on commit 7afa8b1

Please sign in to comment.