因为网络太不安全,我在七月升级了密码策略,订阅 1Password 一年期服务,确实很好用。
但是一个月以后,发现网站被墙了!🤐
我管理自己的密码,还要搭梯子访问,这本身就很危险,于是我回忆那个服务的功能,请 AI 给我写一个类似的程序,大概 2 分钟上就完成了,稍加修改,就能使用。
https://chenzixin.com/ivy/password/
真的是,大多数人十多年的知识积累,在 AI 面前一文不值!
附一通义灵码生成的 Python 程序:
import secrets
import string
def generate_password(length=12):
if length < 8:
print("Warning: Password length should be at least 8 characters.")
length = 8
# 定义密码中可能包含的字符集
alphabet = string.ascii_letters + string.digits + string.punctuation
# 使用secrets模块生成密码
while True:
password = ''.join(secrets.choice(alphabet) 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 string.punctuation for c in password)):
break
return password
# 设置密码长度
password_length = 12
# 生成密码
generated_password = generate_password(password_length)
print(f"Generated Password: {generated_password}")
附二 JavaScript 测试密码强度:
const password = "YourPassword123!";
if (/[a-z]/.test(password) &&
/[A-Z]/.test(password) &&
/\d/.test(password) &&
/[!@#$%^&*(),.?":{}|<>]/.test(password)) {
console.log("密码符合要求");
} else {
console.log("密码不符合要求");
}