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)

  • 相关阅读:
    数据库特性之原子性和一致性
    [linux] 输出重定向与后台运行
    shell编程其实真的很简单(一)
    Java8中的流操作-基本使用&性能测试
    Hadoop到底是干什么用的?
    为什么要有文件系统?文件系统都有哪些种类?
    MySQL insert value与values
    MySQL create语句
    fiddler抓包-简单易操作(二)
    jmeter文件目录说明(一)
  • 原文地址:https://www.cnblogs.com/guolongnv/p/8081471.html
Copyright © 2011-2022 走看看