private void button2_Click(object sender, EventArgs e) { string str = textBox4.Text; int[] flag = { 0, 0, 0, 0 }; for (int i = 0; i < str.Length; i++) { if (str[i] >= '0' && str[i] <= '9') { flag[0] = 1; } else if (str[i] >= 'a' && str[i] <= 'z') { flag[1] = 1; } else if (str[i] >= 'A' && str[i] <= 'Z') { flag[2] = 1; } else if ((str[i] >= 33 && str[i] <= 47) || (str[i] >= 58 && str[i] <= 96) || (str[i] >= 123 && str[i] <= 126)) { flag[3] = 1; } } if (flag[0] == flag[1] && flag[1] == flag[2] && flag[2] == flag[3] && flag[0] == 1 && str.Length >= 8) { FileStream file = new FileStream("details.yos", FileMode.Append); FileStream file1 = new FileStream("password.txt", FileMode.Append); BinaryWriter bw = new BinaryWriter(file); StreamWriter sw = new StreamWriter(file1); Sha s = new Sha(textBox4.Text); bw.Write(textBox5.Text); bw.Write(textBox3.Text); bw.Write(s.GetPassword()); file.Close(); bw.Close(); sw.WriteLine(textBox4.Text); sw.Close(); file1.Close(); update(); } else { MessageBox.Show("Password is not strong!"); } }
private void button1_Click(object sender, EventArgs e) { string str = ""; FileStream file = new FileStream("password.txt", FileMode.Open); StreamReader sr = new StreamReader(file); DialogResult d = MessageBox.Show("Decrypting...", "", MessageBoxButtons.OK); if (d == DialogResult.OK) { while ((str = sr.ReadLine()) != null) { Sha s = new Sha(str); if (s.GetPassword() == textBox2.Text.ToLower()) { break; } } MessageBox.Show(str); } file.Close(); sr.Close(); }