public void WriteData() { if (tbLogin.Text.Length < 6 || tbPassword.Text.Length < 7) { MessageBox.Show("Username or password is too short"); } else { string dir = tbLogin.Text; Directory.CreateDirectory("data\\" + dir); var sw = new StreamWriter("data\\" + dir + "\\data.txt"); string encusr = CryptData.Encrypt(tbLogin.Text); string encpass = CryptData.Encrypt(tbPassword.Text); sw.WriteLine(encusr); sw.WriteLine(encpass); sw.WriteLine(CryptData.getSN()); sw.Close(); MessageBox.Show("User was succesfully created", tbLogin.Text); this.Close(); } }
private void bSignIn_Click(object sender, RoutedEventArgs e) { try { var sr = new StreamReader("data\\" + tbLogin.Text + "\\data.txt"); string encusr = sr.ReadLine(); string encpass = sr.ReadLine(); string serialNumber = sr.ReadLine(); sr.Close(); string decusr = CryptData.Decrypt(encusr); string decpass = CryptData.Decrypt(encpass); if (decusr == tbLogin.Text && decpass == tbPassword.Password && serialNumber == CryptData.getSN()) { MessageBox.Show("Добро пожаловать", decusr); } else { MessageBox.Show("Пароль или логин не правильны."); } } catch (Exception ex) { MessageBox.Show("Пароль или логин не правильны."); } }
//string keyFileName = @"C:\Users\Dauken\source\repos\SerialNumberUse\SerialNumberUse\symmetric_key.config"; public Signup() { InitializeComponent(); tbSerialNumber.Text = CryptData.getSN(); }