def on_change_password(event): password_info = menu.get_password_info() #contains tuple (current password, new password, new password) cur_password = password_info[0] if user_login.get_encrypted_key(name, cur_password) != "": if password_info[1] == password_info[2]: new_password = password_info[1] salt = user_login.get_salt(name) new_pw_hash = Waldo.hash(new_password, salt) user_login.change_password(name, Waldo.encrypt_keytext(key, new_pw_hash), new_pw_hash) menu.set_message("Password has been changed.") else: menu.set_message("New passwords do not match.") else: menu.set_message("Username/password combination was not found.")
def on_login (event): login_info = login.get_login_info() encrypted_key = user_login.get_encrypted_key(login_info[0], login_info[1]) if encrypted_key != "": global name name = login_info[0] password_hashed = Waldo.hash(login_info[1], user_login.get_salt(name)) global key key = Waldo.decrypt_keytext(encrypted_key, password_hashed) global certificate certificate = Waldo.get_cert_from_text(user_login.get_certificate(name)) login.close() else: login.set_message("Username/password combination was not found.")
def on_register (event): register_info = login.get_register_info() #contains tuple (username, password, password) if register_info[1] != register_info[2]: login.set_message("Passwords do not match.") elif len(register_info[1]) < MIN_PASSWORD_LENGTH: login.set_message("Password length must be at least 6 characters long.") elif register_info[0] == "": login.set_message("Please enter a username.") else: name = register_info[0] if user_login.unique_username(name): key = Waldo.get_key() salt = Waldo.salt() password = register_info[1] password_hashed = Waldo.hash(password, salt) user_login.register_user(name, password_hashed, Waldo.encrypt_keytext(key, password_hashed), Waldo.generate_request(name, key), salt) login.login_mode() login.set_message("Account created! You can now login.") else: login.set_message("Username is already used.")
def hasher(event, password, salt): return Waldo.hash(password, salt)