private void xdecrypt_Click(object sender, RoutedEventArgs e) { string filename = ""; Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; dlg.DefaultExt = ""; dlg.Filter = ""; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { filename = dlg.FileName; string temp = System.IO.File.ReadAllText(filename, Encoding.Default); Xtea temp1 = new Xtea(k3.Text, temp); temp = temp1.Decrypt(); string[] t1 = filename.Split('\\'); string[] t2 = t1[t1.Length - 1].Split('ƒ'); string t3 = ""; for (int i = 0; i < t1.Length - 1; i++) { t3 += t1[i] + "\\"; } t3 += t2[0] + "decrypt." + t2[1]; System.IO.File.Copy(filename, t3); System.IO.File.WriteAllText(t3, temp, Encoding.Default); } }
private void log_Click(object sender, RoutedEventArgs e) { string filename = "logpass"; string temp = System.IO.File.ReadAllText(filename); if (lg.Text == "" || ps.Text == "") { MessageBox.Show("Введите данные"); return; } Xtea lg1 = new Xtea("MY WORLDMY WORLD", lg.Text); Xtea ps1 = new Xtea("MY WORLDMY WORLD", ps.Text); string dec1 = lg1.Encrypt(); string dec2 = ps1.Encrypt(); string[] temp1 = temp.Split('\n'); bool b = false; string dec3 = ""; string dec4 = ""; string dec5 = ""; for (int i = 0; i < temp1.Length; i++) { string[] temp2; temp2 = temp1[i].Split('ƒ'); if (dec1 == temp2[0] && dec2 == temp2[1]) { Xtea k11 = new Xtea("MY WORLDMY WORLD", temp2[2]); Xtea k22 = new Xtea("MY WORLDMY WORLD", temp2[3]); Xtea k33 = new Xtea("MY WORLDMY WORLD", temp2[4]); dec3 = k11.Decrypt(); dec4 = k22.Decrypt(); dec5 = k33.Decrypt(); b = true; break; } } if (b == true) { Mein win = new Mein(lg.Text, dec3, dec4, dec5); win.Show(); this.Close(); } else { MessageBox.Show("Данные не верные"); } }
private void xdecry_Click(object sender, RoutedEventArgs e) { Xtea temp = new Xtea(k3.Text, xt.Text); xt.Text = temp.Decrypt(); }