Skip to content

Instantly share code, notes, and snippets.

@inigohidalgo
Created July 11, 2016 09:27
Show Gist options
  • Save inigohidalgo/560f8331d92665fe382a1cf1bc2de738 to your computer and use it in GitHub Desktop.
Save inigohidalgo/560f8331d92665fe382a1cf1bc2de738 to your computer and use it in GitHub Desktop.
import re
uppercaseRegex = re.compile(r'[A-Z]')
lowercaseRegex = re.compile(r'[a-z]')
numberRegex = re.compile(r'\d')
noSymbolRegex = re.compile(r'^\w*$')
def passwordCheck(programName):
while True:
print('Please type your password for ' + programName)
password=input()
moUC = uppercaseRegex.search(password)
moLC = lowercaseRegex.search(password)
moN = numberRegex.search(password)
moNS = noSymbolRegex.search(password)
if len(password)<7:
print('Password not long enough')
elif not moNS:
print('Password must consist only of numbers and letters.')
elif not moUC:
print('Password must have at least one uppercase letter.')
elif not moLC:
print('Password must have at least one lowercase letter.')
elif not moN:
print('Password must have at least one number.')
else:
print('Access granted to '+ programName)
break
program = input('What program do you want to access? ')
passwordCheck(program)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment