示例#1
0
        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 reg_Click(object sender, RoutedEventArgs e)
        {
            string rez      = "";
            string filename = "logpass";

            if (lg1.Text == "" || ps1.Text == "")
            {
                MessageBox.Show("Введите данные"); return;
            }
            if (k1.Text == "" || k2.Text == "" || k3.Text == "" || k1.Text.Length != 4 || k2.Text.Length != 16 || k3.Text.Length != 16)
            {
                MessageBox.Show("Введите ключи"); return;
            }
            Xtea   lg   = new Xtea("MY WORLDMY WORLD", lg1.Text);
            Xtea   ps   = new Xtea("MY WORLDMY WORLD", ps1.Text);
            Xtea   k11  = new Xtea("MY WORLDMY WORLD", k1.Text);
            Xtea   k22  = new Xtea("MY WORLDMY WORLD", k2.Text);
            Xtea   k33  = new Xtea("MY WORLDMY WORLD", k3.Text);
            string dec1 = lg.Encrypt();
            string dec2 = ps.Encrypt();
            string dec3 = k11.Encrypt();
            string dec4 = k22.Encrypt();
            string dec5 = k33.Encrypt();


            string temp = System.IO.File.ReadAllText(filename);

            string[] temp1 = temp.Split('\n');

            bool b = false;

            for (int i = 0; i < temp1.Length; i++)
            {
                string[] temp2;
                temp2 = temp1[i].Split('ƒ');
                if (dec1 == temp2[0])
                {
                    b = true;
                    break;
                }
            }


            if (b == true)
            {
                MessageBox.Show("Такой аккаунт уже существует"); return;
            }

            rez = dec1 + "ƒ" + dec2 + "ƒ" + dec3 + "ƒ" + dec4 + "ƒ" + dec5 + "ƒ" + Environment.NewLine;
            System.IO.File.AppendAllText(filename, rez);
            g1.Visibility = Visibility.Visible;
            g2.Visibility = Visibility.Hidden;
        }
        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("Данные не верные");
            }
        }
示例#4
0
        private void xdecry_Click(object sender, RoutedEventArgs e)
        {
            Xtea temp = new Xtea(k3.Text, xt.Text);

            xt.Text = temp.Decrypt();
        }