博客
关于我
L1-6 检查密码 (15分)
阅读量:342 次
发布时间:2019-03-04

本文共 1778 字,大约阅读时间需要 5 分钟。

密码合法性检查功能开发指南

功能概述

该模块负责对用户注册密码的合法性进行检查,确保密码符合网站设定的安全规则。

输入格式

  • 该模块接受一个正整数N,表示待检查的密码数量
  • 接下来的N行分别为待检查的密码字符串
  • 每个密码字符串满足不超过80个字符且为非空字符串
  • 输出格式

    对每个密码字符串,输出以下类型的反馈信息之一:

  • 如果密码合法,输出:“Your password is wan mei。”
  • 如果密码长度不足6个字符,输出:“Your password is tai duan le。”
  • 如果密码长度符合要求但包含非法字符,输出:“Your password is tai luan le。”
  • 如果密码长度符合要求但仅包含数字,输出:“Your password needs shu zi。”
  • 如果密码长度符合要求但仅包含字母,输出:“Your password needs zi mu。”
  • 实现细节

  • 密码长度检查:首先验证密码长度是否≥6个字符
  • 合法字符检查:允许字母(大小写)、数字和小数点
  • 必要字符组合检查:确保密码中既有字母又有数字
  • 样例分析

    输入样例

    5123szheshi.wodepw1234.5678WanMei23333pass*word.6

    输出样例

    Your password is tai duan le.Your password needs shu zi.Your password needs zi mu.Your password is wan mei.Your password is tai luan le.

    开发注意事项

  • 输入处理:注意密码可能包含空格字符,应使用适当的读取方式
  • 正则表达式优化:可使用正则表达式简化合法字符检查
  • 性能优化:确保在处理大量密码时依然保持高效率
  • 常见问题

  • 为什么密码长度检查放在第一位?
    • 由于密码长度是基本的安全要求,优先检查可以提升效率
  • 是否需要考虑特殊符号?
    • 根据要求不需要,仅允许字母、数字和小数点
  • 技术实现

    #include 
    #include
    #include
    int main() { int n; scanf("%d\n", &n); while (n--) { char password[100]; gets(password); if (strlen(password) < 6) { printf("Your password is tai duan le.\n"); continue; } int has_letter = 0, has_digit = 0; for (int i = 0; password[i]; i++) { if (isdigit(password[i])) has_digit = 1; else if (isalpha(password[i])) has_letter = 1; else if (password[i] == '.') continue; else { printf("Your password is tai luan le.\n"); goto loop; } } if (!has_letter && has_digit) { printf("Your password needs zi mu.\n"); } else if (has_letter && !has_digit) { printf("Your password needs shu zi.\n"); } else { printf("Your password is wan mei.\n"); } loop:; }}

    转载地址:http://vpwe.baihongyu.com/

    你可能感兴趣的文章
    NLP问答系统:使用 Deepset SQUAD 和 SQuAD v2 度量评估
    查看>>
    NLP项目:维基百科文章爬虫和分类【02】 - 语料库转换管道
    查看>>
    NLP:使用 SciKit Learn 的文本矢量化方法
    查看>>
    nmap 使用方法详细介绍
    查看>>
    Nmap扫描教程之Nmap基础知识
    查看>>
    nmap指纹识别要点以及又快又准之方法
    查看>>
    Nmap渗透测试指南之指纹识别与探测、伺机而动
    查看>>
    Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
    查看>>
    NMAP网络扫描工具的安装与使用
    查看>>
    NMF(非负矩阵分解)
    查看>>
    nmon_x86_64_centos7工具如何使用
    查看>>
    NN&DL4.1 Deep L-layer neural network简介
    查看>>
    NN&DL4.3 Getting your matrix dimensions right
    查看>>
    NN&DL4.7 Parameters vs Hyperparameters
    查看>>
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    nnU-Net 终极指南
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    NO 157 去掉禅道访问地址中的zentao
    查看>>
    no available service ‘default‘ found, please make sure registry config corre seata
    查看>>
    No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    查看>>