zoukankan      html  css  js  c++  java
  • 用python实现密码校验程序

    密码需要符合下面的要求:

    8个字符以上,包含数字,大小写,开头不能为特殊字符。

    #! /usr/bin/python
    import re

    password = str(input())

    def lenOK(pwd):
        if(len(pwd)>=8):
            return True
        else:
            print("WARNING: The password should be at least 8 characters.")
            return False

    def numberOK(pwd):
        pattern = re.compile('[0-9]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 number.")
            return False

    def upperOK(pwd):
        pattern = re.compile('[A-Z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 upper character.")
            return False

    def lowerOK(pwd):
        pattern = re.compile('[a-z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 lower character.")
            return False

    def symbolOK(pwd):
        pattern = re.compile('^[a-z0-9A-Z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should start with numbers or characters.")
            return False

    def checkpwd(pwd):
        check = lenOK(pwd) and numberOK(pwd) and upperOK(pwd) and lowerOK(pwd) and symbolOK(pwd)
        if (check):
            print("The password is legal.")
        else:
            print(check)

    checkpwd(password)

  • 相关阅读:
    [转]项目需求范围管理
    JavaScript 王者归来
    [转]大文件上传组件
    [转]使用vs2005自带的sql2005 express
    JS判断Caps Lock
    [转]Web项目管理思考
    [转]JS严格验证身份证
    两分钟用C#搭建IE BHO勾子, 窃取密码
    asp.net性能提升十个方法(Microsoft)
    [转]Asp.net 将js文件打包进dll 方法
  • 原文地址:https://www.cnblogs.com/guolongnv/p/8081471.html
Copyright © 2011-2022 走看看