需要协助python密码强度点系统,我的系统需要减去积分

时间:2017-10-01 20:24:50

标签: python python-3.x passwords

checkpassword2()中,如果密码只有一个小写或大写字母,或者数字0-9或符号,则程序应减去5个点。我不需要确切的方法来提示如何到达那里。

import random

string = 'abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$%^&*()-_=+'

def mainmenu():

    print('1. Check Password.')
    print('2. Generate Password.')
    print('3. Quit.')
    choice = int(input('Choice:'))

    while True:
        try:
            if choice == 1 :
                checkpass1()
                break

            elif choice == 2 :
                generatepass()
                break

            elif choice == 3 :
                print('Bye')
                break

            else :
                print('Invalid Choice Please Enter Again')
                mainmenu()

        except ValueError:
            print('Please Enter A Value Between 1 & 3')


    exit


def checkpass1():

    global password

    print('Please Enter Your Password')
    password=input('Password:')
    length= str(len(password))

    if len(password) <8 or len(password) >24:
        print('you password should be between 8 and 24 characters, please input again')
        checkpass1()
    else:
        checkpass2()

    checkpass2()

def checkpass2():

    global password, score

    score = len(password)
    if re.search(r'[0-9]', password):
        score= score + 5
    if re.search(r'[A-Z]', password):
        score= score + 5
    if re.search(r'[0-9]', password):
        score= score + 5
    if re.search(r'[!$%^&*()-_=+]', password):
        score= score + 5
    if score is >15:
        score= score + 10

#menu start
mainmenu()

0 个答案:

没有答案