专栏中心

EEPW首页 > 专栏 > 基于 Python 的密码强度检测工具

基于 Python 的密码强度检测工具

发布人:小橘子lala 时间:2025-01-02 来源:工程师 发布文章

import re # 密码强度检测函数 def check_password_strength(password):    score = 0    if len(password) >= 8:        score += 1    if re.search(r'[a-z]', password) and re.search(r'[A-Z]', password):        score += 1    if re.search(r'\d', password):        score += 1    if re.search(r'[^\w]', password):        score += 1    return score # 示例密码列表 passwords = [    "abcdef",    "Abcdefg",    "Abcdefg1",    "Abcdefg1!",    "StrongP@ssw0rd" ] for password in passwords:    strength = check_password_strength(password)    print(f"密码 '{password}' 的强度评分为 {strength} 分")

专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词:
更多 培训课堂
更多 焦点
更多 视频

技术专区