private void button1_Click(object sender, EventArgs e) { string Key = textBox1.Text.ToString(); if (textBox1.Text == null) { MessageBox.Show("Mật khẩu chưa nhập! ", "Thông báo", MessageBoxButtons.OK); } if (int.Parse(Key) % 2 == 0) { using (MD5 md5 = MD5.Create()) { string hash = GetMd5Hash(md5, Key); System.IO.StreamWriter str = System.IO.File.AppendText("user.txt"); str.WriteLine(hash); str.Close(); this.Hide(); StartScreen startScreen = new StartScreen(); startScreen.ShowDialog(); this.Close(); } } else { MessageBox.Show("Sai mật khẩu! ", "Thông báo", MessageBoxButtons.OK); } }
private void KeyLogin_Load(object sender, EventArgs e) { if (!System.IO.File.Exists("user.txt")) { var myfile = System.IO.File.Create("user.txt"); myfile.Close(); } string pass = System.IO.File.ReadAllText("user.txt"); if (pass.Length != 0) { this.Hide(); StartScreen startScreen = new StartScreen(); startScreen.ShowDialog(); this.Close(); } }