from easygui import * #The next part makes 'checkpw' equals to what the user enters def getpassword(checkpw): checkpw = passwordbox("Please enter the Password to be tested","Password Strength Tester") #remove title= if checkpw == None: checkpw = " " return(checkpw) def checkpassword(): checkpw = "" checkpw = getpassword(checkpw) #The next part checks the length of the user inputted password to see whether it is between 6 and 12 characters if len(checkpw) > 5 and len(checkpw) <= 12: #change length >6 to >5 uppercase = 0 lowercase = 0 number = 0 other = 0 #This next part checks, using ascii-code, each letter and whether the character is a number, lowercase, uppercase and other (punctuation) #And assigns a value to each. It then adds up the values to make a total 'strength' for eachletter in checkpw: asciicode = ord(eachletter) if asciicode >= 97 and asciicode <=122: uppercase = 1 elif asciicode >= 65 and asciicode <=90: lowercase = 1 elif asciicode >= 48 and asciicode <=57: number = 1 else: other = 1 strength = lowercase + uppercase + number + other #This part is an if statement stating what strength needs to be equals to for a weak, medium, strong and very strong password. if strength == 1: printmsg = "Your password is WEAK." #There was a spelling error here, I changed "WAEK" to "WEAK" elif strength == 2: printmsg = "Your password has a MEDIUM strength." elif strength == 3: printmsg = "You have a STRONG password." else: printmsg = "You have a VERY STRONG password." msgbox(printmsg,"Password is acceptable.") #The next part will display a message stating that the password should be 12-16 words long and then it changes goagain to true #Enabling the while clause. else: msgbox ("Password needs to be between 6 and 12 characters in length","Password Error") #Change "error" to "Error" if __name__ == '__main__': goagain = True while goagain: checkpassword() goagain = boolbox("Test another password?","Password Strength")#Spelling error (changed "Passwrd" to "Password")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question