Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import json
- class Utilizator:
- def __init__(self):
- super().__init__()
- self.email_utilizator = None
- def inregistrare(self):
- email = input("Introduceti adresa de email: ")
- confirmare = False
- while not confirmare:
- parola = input("Introduceti parola: ")
- parola_confirmare = input("Confirmati parola: ")
- if parola != parola_confirmare:
- print("Cele doua parole nu coincid!")
- else:
- confirmare = True
- enc = parola.encode()
- hash1 = hashlib.md5(enc).hexdigest()
- client = email + parola
- client_enc = client.encode()
- client_hash = hashlib.md5(client_enc).hexdigest()
- json_object = {str(client_hash):[{"email": email, "password": hash1}]}
- inputfile = open('credentials.json')
- json_object_loaded = json.load(inputfile)
- if client_hash in json_object_loaded:
- print("Acest cont exista!")
- return
- dict_final = {**json_object_loaded, **json_object}
- with open("credentials.json", "w") as outfile:
- outfile.write(json.dumps(dict_final))
- outfile.close()
- print("Te-ai inregistrat cu succes!")
- def conectare(self):
- email = input("Introduceti adresa de email: ")
- parola = input("Introduceti parola: ")
- client = email + parola
- client_enc = client.encode()
- client_hash = hashlib.md5(client_enc).hexdigest()
- inputfile = open('credentials.json')
- json_object_loaded = json.load(inputfile)
- if client_hash in json_object_loaded:
- print("Te-ai conectat cu succes!")
- self.email_utilizator = email
- return True
- else:
- print("Datele sunt incorecte!")
- def cardValidate(number) :
- lenght = len(number)
- digits = [int(x) for x in str(number)]
- print(digits)
- for el in range(1, lenght, 2):
- digits[el] *= 2
- if digits[el] >= 9:
- digits[el] = int(digits[el] % 10 + (digits[el] / 10) % 10)
- print(digits)
- digits_sum = 0
- for i in range(lenght - 1):
- digits_sum += digits[i]
- print(digits_sum)
- prod_check = digits_sum * 9
- if prod_check % 10 == digits[lenght - 1]:
- print("Cardul e valid")
- if __name__ == '__main__':
- aplicatie = Utilizator()
- while 1:
- print("********** Online Banking **********")
- print("1.Inregistrare")
- print("2.Conectare")
- print("3.Exit")
- ch = int(input("Alegerea dumneavoastra: "))
- if ch == 1:
- aplicatie.inregistrare()
- elif ch == 2:
- conectare = aplicatie.conectare()
- if conectare:
- break
- elif ch == 3:
- break
- else:
- print("Wrong Choice!")
- while conectare:
- print("********** Alege furnizorii ********** Utilizator: ", aplicatie.email_utilizator)
- inputfile = open('furnizori.json')
- json_object_loaded = json.load(inputfile)
- print(json_object_loaded)
- for key, value in json_object_loaded.items():
- print(value)
- card = input("Introduceti numarul cardului")
- cardValidate(str(card))
- conectare = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement