Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Login system
#1
Hi! i developed a "basic" program to school project and need to be done sunday but im having a problem i dont know how to use a login system there is the program:

I made the file BUT i need to check in the file if it is already created the student_number and is password and also ask if u wanna modify ur "login" (the student number and password).

I dont know if i was clearly but i did my best Wall

import binascii
import re
def crc32(text):
 return binascii.crc32( str(text).encode() )& 0xffffffff

student_number = ("")

def dados():
    
    student_number = input("Enter your student number: ")
    
    if (len(student_number)) < 7 or (len(student_number)) > 7:
        print ("Deve conter 7 digitos!")
        dados()
    else:
        print("Sucesso!!")
        print ("\nO seu número é:",student_number)
        work_code = crc32(student_number)
        print ( "\nYour work code is: ",work_code )
dados()
   



print ("")
print ("A password deve possuir as seguintes regras:")
print ("D1 Apenas possuir 1 maiuscula")
print ("D2 Pelo menos 2 minusculas")
print ("D3 Deve usar 2 do set [! # - * + @ & % _]")
print ("D5 Apenas 1 Digito")
print ("")
print ("Mas NÃO pode possuir:")
print ("x2 Começar por um carater especial")
print ("x4 Mais que 10 caracteres")
print ("")

minusc = 2
maiusc = 1
carac = 2
num = 1                



def repete():

    student_pass = input ("Insira a sua password: ")    
    user_input = input (" Confirme a sua password: ")
    
    if student_pass != user_input:
        
        user_input = input ("Confirme a sua password: ")
        print ("")
    
    check1 = False
    check2 = False
    check3 = False
    check4 = False
    check5 = False
    check6 = False

    while True:
        arq = open ('passwd.txt' , 'r')
        if data = arq.readline (

    
        #regra x4
    if(len(user_input)>10):
        print ("Não pode conter mais de 10 caracteres ---------- XXX Falhou a regra")
    else:
        print("Não pode conter menos de 10 caracteres   ---------- OK")
        check1 = True
        #regra D2
        
    if len(re.findall("[a-z]",user_input)) >= minusc:
        print ("Precisa de conter duas minusculas ---------- OK")
        check2 = True
    else:
        print("Precisa de conter duas minusculas ---------- XXX Falhou a regra")
       

        #regra D5
    if len(re.findall("[0-9]",user_input)) == num:
        print("Tem de possuir apenas um numero -------- OK")
        check3 = True
    else:
        print("Tem de possuir apenas um numero -------- XXX Falhou a regra")
        
        
        #regra D3
    if len(re.findall("[~!@#$%^&*`+=|\;:><,.?/]",user_input)) >= carac:
        print("Tem de possuir pelo menos dois caracter ----- OK")
        check4 = True
    else:
        print("Tem de possuir pelo menos dois caracter ----- XXX Falhou a regra")
        
        
        #regra x2
    if re.search("[~!@#$%^&*`+=|\;:><,.?/]",user_input[0]):
        print("A primeira letra não pode ser um caracter ----- XXX Falhou a regra")
    else:
        print("A primeira letra não pode ser um caracter ------- OK")
        check5 = True

        #regra D1
    if len(re.findall("[A-Z]",user_input)) == maiusc:
        print("Precisa de conter apenas 1 maiuscula ------- OK")
        check6 = True
    else:
        print("Precisa de conter apenas 1 maiuscula ------ XXX Falhou a regra")
       


    if check1 == False or check2 == False or check3 == False or check4 == False or check5 == False or check6 == False:
        print("Não cumpre os requisitos pedidos Insira novamente")
        print("")
        repete()       
    
    else:
        print()
        print('Sucesso!')
        fich_code32 = crc32(student_pass)
        print (fich_code32)
        arq = open('passwd.txt', 'a')
        arq.write("Numero do aluno: ")
        arq.write(str(student_number))
        arq.write("\nPass do aluno: ")
        arq.write(str(fich_code32))
        arq.write("\n")
        
        
        arq.close()
        repete()
    return False

      
repete()
Reply
#2
I haven't tried the program, but I would note that you have a problem with student_number. You get it in the dados function, but you don't return it from there, so you can't use it in the repete function. You need to return the value from dados, assign that to a variable, and pass that to repete as a parameter. See the function tutorial link in my signature below for examples.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
is working fine the command . for now i can introduce the student_number and also the password in the .txt
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Login/register system. Exploiterz 5 3,858 May-15-2018, 05:32 PM
Last Post: wavic
  User sign up and login system tesilstudent112 1 5,050 Oct-22-2017, 10:14 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020