Demo entry 6683251

Program

   

Submitted by anonymous on Dec 12, 2017 at 15:46
Language: Python 3. Code size: 8.8 kB.

def CheckPassword():
    password = str(input("Please enter a password that you would like to get checked. "))
    LengthCheck(password)
    
def LengthCheck(password):
    point = 0
    ps = password
    length = len(ps)
    if length < 8:
        print("The length of the password is not the right size. Please enter another password.")
        main()
    elif length > 24:
        print("The length of the password is not the right size. Please enter another password.")
        main()
    else:
        TypeOfLetter(ps,length, point)
    
def TypeOfLetter(password, length, point):
    pt = point
    i = 0
    ps = password
    le = length
    while i < le:
        char = ord(password[i])
        if char < 32:
            print("That is not a valid password. It can only contain ! $ % ^ & ( ) - _ = + numbers and letters.")
            main()
        elif char > 122:
            print("That is not a valid password. It can only contain ! $ % ^ & ( ) - _ = + numbers and letters. ")
            main()
        elif char == 34 or char == 39 or char == 44 or char == 46 or char == 47 or char == 58 or char == 59 or char == 60 or char == 62 or char == 63 or char == 64 or char == 91 or char == 92 or char == 93 or char == 96:
            print("That is not a vaild password. It can only contain ! $ % ^ & ( ) - _ = + numbers and letters.")
            main()
        i = i + 1
    QWERTY(ps, pt)

def QWERTY(password, point):
    ps = password
    pt = point
    ListLetter = ["qwe","Qwe", "qWe", "qwE", "QWe", "QwE", "qWE", "QWE", "wer","Wer","wEr","weR","WEr","WeR","wER","WER","ert","ERT","Ert","eRt","erT","ERt","ErT","eRT","rty","Rty","rTy","rtY","RTy","RtY","rTY","RTY","tyu","Tyu","tYu","tyU","TYu","TyU","tYU","TYU","yui","Yui","yUi","yuI","YUi","YuI","yUI","YUI","uio","Uio","uIo","uiO","UIo","UiO","uIO","UIO","iop","Iop","iOp","ioP","IOp","IoP","iOP","IOP","asd","Asd","aSd","asD","ASd","AsD","aSD","ASD","sdf","Sdf","sDf","sdF","SDf","SdF","sDF","SDF","Dfg","dFg","dfG","DFg","DfG","dFG","DFG","dfg","fgh","Fgh","fGh","fgH","FGh","FgH","fGH","FGH","ghj","Ghj","gHj","ghJ","GHj","GhJ","gHJ","GHJ","hjk","Hjk","hJk","hjK","HJk","HjK","hJK","HJK","jkl","Jkl","jKl","jkL","JKl","JkL","jKL","JKL","zxc","Zxc","zXc","zxC","ZXc","ZxC","zXC","ZXC","xcv","Xcv","xCv","xcV","XCv","XcV","xCV","XCV","cvb","Cvb","cVb","cvB","CVb","CvB","cVB","CVB","vbn","Vbn","vBn","vbN","VBn","VbN","vBN","VBN","bnm","Bnm","bNm","bnM","BNm","BnM","bNM","BNM"]
    length = len(ps) - 3
    r = 0
    t = r+1
    y = r + 2
    repeat = 0
    ps[r]
    ps[t]
    ps[y]
    
    while r <= length:
        i = 0
        while i < 160:
            if ps[r] + ps[t] + ps[y] == ListLetter[i]:
                repeat = repeat + 1
                i = i + 1
            else:
                i = i + 1
        r = r + 1
        t = t + 1
        y = y + 1
    q = repeat * 5
    pt = pt - q
    scoring(ps, pt)
    

def scoring(password, point):
    pt = point
    ps = password
    length = len(password)
    n_length = length - 1
    i = 0
    non = 0
    pt = pt + length
    upper = False
    lower = False
    number = False
    character = False
    while i <= n_length:
        if ord(ps[i]) >= 65 and ord(ps[i]) <= 90:
            upper = True
            

        if ord(ps[i]) >=97 and ord(ps[i]) <= 122:
            lower = True

        if ord(ps[i]) >= 48 and ord(ps[i]) <= 57:
            number = True
            
        if ord(ps[i]) == 33 or ord(ps[i]) == 36 or ord(ps[i]) == 37 or ord(ps[i]) == 38 or ord(ps[i]) == 40 or ord(ps[i]) == 41 or ord(ps[i]) == 42 or ord(ps[i]) == 43 or ord(ps[i]) == 45 or ord(ps[i]) == 61 or ord(ps[i]) == 94 or ord(ps[i]) == 95:
            character = True
            
        i = i + 1
            
    if number == False and character == False:
        pt = pt - 5
        
    if upper == False and lower == False and character == False:
        pt = pt - 5
        
    if upper == False and lower == False and number == False:
        pt = pt - 5
        
    if upper == True:
        pt = pt + 5
        
    if lower == True:
        pt = pt + 5
        
    if number == True:
        pt = pt + 5
        
    if character == True:
        pt = pt + 5
        
    if number == True and lower == True and upper == True and character == True:
        pt = pt + 10

        
    if pt <= 0:
        print("Your password is weak")
        print(pt)
        main()
        
    elif pt >= 20:
        print("yout password is strong")
        print(pt)
        main()
    else:
        print("Your password is medium")
        print(pt)
        main()
        
def main():
    where = input("You can check a password strength (1), generate a password (2) or quit(3). ")
    if where == "1":
        CheckPassword()
    elif where == "2":
        GeneratePassword()
    elif where == "3":
        return
    else:
        print("That is not a valid input. ")
        main()

def GeneratePassword():
    import random as r
    pt = 0
    clear = False
    while clear == False:
        length = r.randint(8, 24)
        i = 0
        ps = ""
        while i <= length:
            char = r.randint(33, 122)
            if char == 34 or char == 39 or char == 44 or char == 46 or char == 47 or char == 58 or char == 59 or char == 60 or char == 62 or char == 63 or char == 64 or char == 91 or char == 92 or char == 93 or char == 96:
                clear = False
            else:
                l = chr(char)
                ps = ps + l
                i = i + 1

        
        ListLetter = ["qwe","Qwe", "qWe", "qwE", "QWe", "QwE", "qWE", "QWE", "wer","Wer","wEr","weR","WEr","WeR","wER","WER","ert","ERT","Ert","eRt","erT","ERt","ErT","eRT","rty","Rty","rTy","rtY","RTy","RtY","rTY","RTY","tyu","Tyu","tYu","tyU","TYu","TyU","tYU","TYU","yui","Yui","yUi","yuI","YUi","YuI","yUI","YUI","uio","Uio","uIo","uiO","UIo","UiO","uIO","UIO","iop","Iop","iOp","ioP","IOp","IoP","iOP","IOP","asd","Asd","aSd","asD","ASd","AsD","aSD","ASD","sdf","Sdf","sDf","sdF","SDf","SdF","sDF","SDF","Dfg","dFg","dfG","DFg","DfG","dFG","DFG","dfg","fgh","Fgh","fGh","fgH","FGh","FgH","fGH","FGH","ghj","Ghj","gHj","ghJ","GHj","GhJ","gHJ","GHJ","hjk","Hjk","hJk","hjK","HJk","HjK","hJK","HJK","jkl","Jkl","jKl","jkL","JKl","JkL","jKL","JKL","zxc","Zxc","zXc","zxC","ZXc","ZxC","zXC","ZXC","xcv","Xcv","xCv","xcV","XCv","XcV","xCV","XCV","cvb","Cvb","cVb","cvB","CVb","CvB","cVB","CVB","vbn","Vbn","vBn","vbN","VBn","VbN","vBN","VBN","bnm","Bnm","bNm","bnM","BNm","BnM","bNM","BNM"]
        length = len(ps) - 3
        r = 0
        t = r+1
        y = r + 2
        repeat = 0
        ps[r]
        ps[t]
        ps[y]
        
        while r <= length:
            i = 0
            while i < 160:
                if ps[r] + ps[t] + ps[y] == ListLetter[i]:
                    repeat = repeat + 1
                    i = i + 1
                else:
                    i = i + 1
            r = r + 1
            t = t + 1
            y = y + 1
    
        q = repeat * 5
        pt = pt - q
        
        length = len(ps)
        i = 0
        non = 0
        while i <= length - 1:
            if ord(ps[i]) >= 65 or ord(ps[i]) <= 90:    
                upper = True
    
            if ord(ps[i]) >=97 or ord(ps[i]) <= 122:
                lower = True
    
            if ord(ps[i]) >= 48 or ord(ps[i]) <= 57:
                number = True
            if ord(ps[i]) == 33 or ord(ps[i]) == 36 or ord(ps[i]) == 37 or ord(ps[i]) == 38 or ord(ps[i]) == 40 or ord(ps[i]) == 41 or ord(ps[i]) == 42 or ord(ps[i]) == 43 or ord(ps[i]) == 45 or ord(ps[i]) == 61 or ord(ps[i]) == 94 or ord(ps[i]) == 95:
                character = True
            i = i + 1
                
        if number == False and character == False:
            pt = pt - 5
            
        if upper == False and lower == False and character == False:
            pt = pt - 5
        
        if upper == False and lower == False and number == False:
            pt = pt - 5
        
        if upper == True:
            pt = pt + 5
            
        if lower == True:
            pt = pt + 5
        
        if number == True:
            pt = pt + 5
            
        if character == True:
            pt = pt + 5
           
        if number == True and lower == True and upper == True and character == True:
            pt = pt + 10
    
            
        if pt <= 0:
            clear = False
            
        elif pt >= 20:
            clear = True
            
        else:
            clear = False
    print("Good password would be: ")
    print(ps)
    main()

main()

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).