private void btnRegister_Click(object sender, EventArgs e) { try { string data = "REGISTER " + txtName.Text + ";" + StringCipher.Hash(txtPass.Text); client.Send(Encoding.UTF8.GetBytes(StringCipher.Encrypt(data, passPhrase))); string response = Receive(1024); if (response == "OK") { Hide(); frmMessageClient form = new frmMessageClient(txtName.Text, client); form.ShowDialog(); Close(); } else { MessageBox.Show("That username is already in use on this server!"); txtName.Text = ""; txtPass.Text = ""; } } catch (SocketException) { MessageBox.Show("Failed to connect to server!"); return; } }
private void btnLogin_Click(object sender, EventArgs e) { try { string data = "LOGIN " + txtName.Text + ";" + StringCipher.Hash(txtPass.Text); client.Send(Encoding.UTF8.GetBytes(StringCipher.Encrypt(data, passPhrase))); string response = Receive(1024); if (response == "OK") { Hide(); frmMessageClient form = new frmMessageClient(txtName.Text, client); form.ShowDialog(); Close(); } else if (response == "BANNED") { MessageBox.Show("That account is banned from the server!"); } else if (response == "LOGGEDIN") { MessageBox.Show("Someone is already logged into this account!"); } else { // THERE IS A PROBLEM WITH CIPHER CUZYOU GET NONSENSE AS RESPONSE MessageBox.Show("Failed to login with those credentials!"); txtName.Text = ""; txtPass.Text = ""; } } catch (SocketException) { MessageBox.Show("Failed to connect to server!"); return; } }