private void UserSignIn(string username, string password) { string hashed_password = sha256(password); MessageBox.Show(hashed_password); //send username and password to python and checks if correct string info = username + "#" + hashed_password; // Open the named pipe. var server = new NamedPipeServerStream("Communicate"); server.WaitForConnection(); var br = new BinaryReader(server); var bw = new BinaryWriter(server); send(bw, info); string message = recv(br); server.Close(); server.Dispose(); //if receives true then send the user to the next gui. if (message == "1") { SaveFile form = new SaveFile(); form.Show(); } else { MessageBox.Show("incorrect password or username"); this.Show(); } }
private void UserSignIn(string username, string password) { if (username == "") { MessageBox.Show("Please enter username"); this.Show(); } else if(password == "") { MessageBox.Show("Please enter password"); this.Show(); } else { string hashed_password = sha256(password); //send username and password to python and checks if correct string info = "login#" + username + "#" + hashed_password; // Open the named pipe. var server = new NamedPipeServerStream("Communicate"); server.WaitForConnection(); var br = new BinaryReader(server); var bw = new BinaryWriter(server); send(bw, info); string message_to_split = recv(br); message_to_split = message_to_split + recv(br); string message = message_to_split.Split('#')[0]; if (message_to_split.Split('#')[1] != "0") { this.my_uid = message_to_split.Split('#')[2]; this.firstname = message_to_split.Split('#')[1]; this.lastname = message_to_split.Split('#')[3]; MessageBox.Show(my_uid + firstname + lastname); } server.Close(); server.Dispose(); //if receives true then send the user to the next gui. if (message == "Signed in") { string user_info = this.my_uid + "#" + this.firstname + "#" + this.lastname; SaveFile form = new SaveFile(user_info); form.Show(); } else { MessageBox.Show("incorrect password or username"); this.Show(); } } }