| 12345678910111213141516171819202122232425262728293031323334353637 |
- import os
- # Module to hide password input
- import getpass
- # Clear screen
- os.system("clear") # Mac or Linux
- #os.system("cls") # Windows
- # Get user input (will not show in terminal upon input)
- userInput = getpass.getpass("Input a password: ")
- # Reset criteria to unfulfilled
- letterCriteria = False
- numberCriteria = False
- lengthCriteria = False
- # Check length criteria (>= 12 characters long)
- # Store true or false in variable lengthCriteria
- lengthCriteria = len(userInput) >= 12
- # Iterate the password, character by character
- for i in userInput:
- # Test if character is alpha
- # If so, set letterCriteria to true (critera fulfilled)
- if i.isalpha():
- letterCriteria = True
- # Test if character is digit
- # If so, set numberCriteria to true (critera fulfilled)
- if i.isdigit():
- numberCriteria = True
- # Check if all critera is fulfilled (variables are True)
- if letterCriteria and numberCriteria and lengthCriteria:
- print("Password fulfilled all the criteria.")
- else:
- print("Password must contain at least one letter and one digit, and contain at least 12 characters.")
|