Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import exit
- import re
- import os.path
- import zlib
- #Pelo menos 2 minusculas
- def check_lower(input):
- lowers = 0
- lower_list = "a b c d e f g h i j k l m n o p q r s t u v w x y z".split()
- for char in input:
- if char in lower_list:
- lowers += 1
- if lowers > 1:
- return True
- else:
- return False
- def check_special(input):
- specials = 0
- special_list = "a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 ' ' ! # - * + & % @ _".split() #NAO PODE VER EM CASA
- for char in input:
- if char in special_list:
- specials += 1
- if specials > 0:
- return True
- else:
- return False
- def check_len(input):
- if len(input) >= 8:
- return True
- else:
- return False
- def comecar_letra(input):
- lista_char = "a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split()
- for char in input:
- if char[0] in lista_char:
- return True
- else:
- return False
- def duasminusculasseguidas(input):
- checker = re.compile(r'([a-z][a-z])')
- if re.search(checker, input):
- return True
- else:
- return False
- def registo():
- file = open("Contas.txt","a")
- file.write(numeroaluno)
- file.write(" ")
- file.write(password)
- file.write("\n")
- file.close()
- def verificar():
- try:
- for line in open("Contas.txt","r").readlines(): # Read the lines
- login_info = line.split()
- if numeroaluno == login_info[0]:
- print("Ja existe esse numero de aluno")
- else:
- registo()
- except:
- file = open("Contas.txt","a")
- file.close()
- registo()
- def validate_password(input):
- check_dict = {
- 'lower': check_lower(input),
- 'minus': duasminusculasseguidas(input),
- 'special': check_special(input),
- 'len' : check_len(input),
- 'let' : comecar_letra(input)
- }
- if check_lower(input) & check_special(input) & check_len(input) & comecar_letra(input) & duasminusculasseguidas(input):
- return True
- else:
- print ("Password Invalida! Verifica os problemas seguintes !")
- print
- if check_dict['lower'] == False:
- print ("Password tem de ter pelo menos 2 caracteres minusculos.")
- if check_dict['special'] == False:
- print ("Password needs at least one special character.")
- if check_dict['len'] == False:
- print ("Password tem de ter pelo menos 8 caracteres.")
- if check_dict['let'] == False:
- print ("Password tem de comecar por 1 letra.")
- if check_dict['minus'] == False:
- print ("Password precisa de ter 2 letras minusculas consecutivas")
- print
- numeroaluno = input("Introduza o numero do aluno: ")
- while True:
- password = input("Introduza uma password: ")
- print
- if validate_password(password):
- print ("Requerimentos da password foram compridos.")
- print
- # print (hex(zlib.crc32(b'pedro') & 0xffffffff))
- verificar()
- print
- exit(0)
Add Comment
Please, Sign In to add comment