Exemple #1
0
        private async void generate_Click(object sender, RoutedEventArgs e)
        {
            long textLen = 0;

            if (checkLsfr(poly1.Text, init1.Text) == true &&
                checkLsfr(poly2.Text, init2.Text) == true &&
                checkLsfr(poly3.Text, init3.Text) == true &&
                checkNumer(len.Text) && long.TryParse(len.Text, out textLen))
            {
                lfsr _1 = new lfsr(poly1.Text, init1.Text);
                lfsr _2 = new lfsr(poly2.Text, init2.Text);
                lfsr _3 = new lfsr(poly3.Text, init3.Text);
                geffe = new geffe(_1, _2, _3);

                string test = await Task.Run(() => gen(geffe, textLen));

                result.Text = test;
                int  tryParse = -1;
                bool res      = int.TryParse(number.Text, out tryParse);
                if (!res || (tryParse < 1 && tryParse > 2900))
                {
                    string dirName = DateTime.Now.ToString("yyyy_dd_M HH_mm_ss");
                    System.IO.Directory.CreateDirectory(@".\Data\");
                    System.IO.Directory.CreateDirectory(@".\Data\user\" + dirName);
                    using (System.IO.StreamWriter fileResult = new System.IO.StreamWriter(@".\Data\user\" + dirName + @"\lsfr1.txt"))
                    {
                        fileResult.WriteLine(poly1.Text);
                        fileResult.WriteLine(init1.Text);
                    }
                    using (System.IO.StreamWriter fileResult = new System.IO.StreamWriter(@".\Data\user\" + dirName + @"\lsfr2.txt"))
                    {
                        fileResult.WriteLine(poly2.Text);
                        fileResult.WriteLine(init3.Text);
                    }
                    using (System.IO.StreamWriter fileResult = new System.IO.StreamWriter(@".\Data\user\" + dirName + @"\lsfr3.txt"))
                    {
                        fileResult.WriteLine(poly3.Text);
                        fileResult.WriteLine(init3.Text);
                    }
                    using (System.IO.StreamWriter fileResult = new System.IO.StreamWriter(@".\Data\user\" + dirName + @"\result.txt"))
                    {
                        fileResult.Write(result.Text);
                    }
                }
                else
                {
                    using (System.IO.StreamWriter fileResult = new System.IO.StreamWriter(@".\Data\results\" + number.Text + "_" + len.Text + @".txt"))
                    {
                        fileResult.Write(result.Text);
                    }
                }
            }
            else
            {
                var resut = MessageBox.Show("Coś poszło nie tak, sprawdź wszystkie pola jeszcze raz.", "Błąd");
            }
        }
Exemple #2
0
        private async void decode(object sender, RoutedEventArgs e)
        {
            if (checkLsfr(poly1.Text, init1.Text) == true &&
                checkLsfr(poly2.Text, init2.Text) == true &&
                checkLsfr(poly3.Text, init3.Text) == true &&
                checkInit(result.Text))
            {
                lfsr _1 = new lfsr(poly1.Text, init1.Text);
                lfsr _2 = new lfsr(poly2.Text, init2.Text);
                lfsr _3 = new lfsr(poly3.Text, init3.Text);
                geffe = new geffe(_1, _2, _3);
                string s    = result.Text;
                string test = await Task.Run(() => de(geffe, s));

                result.Text = test;
            }
            else
            {
                var resut = MessageBox.Show("Coś poszło nie tak, sprawdź wszystkie pola jeszcze raz.", "Błąd");
            }
        }
Exemple #3
0
        private async void generate_Click(object sender, RoutedEventArgs e)
        {
            if (checkLsfr(poly1.Text, init1.Text) == true &&
                checkLsfr(poly2.Text, init2.Text) == true &&
                checkLsfr(poly3.Text, init3.Text) == true &&
                result.Text.Length < 1000000 && checkText(result.Text))
            {
                lfsr _1 = new lfsr(poly1.Text, init1.Text);
                lfsr _2 = new lfsr(poly2.Text, init2.Text);
                lfsr _3 = new lfsr(poly3.Text, init3.Text);
                geffe = new geffe(_1, _2, _3);
                string s    = result.Text;
                string test = await Task.Run(() => gen(geffe, s));

                result.Text = test;
                MessageBox.Show("Wygenerowano klucz o długości: " + test.Length.ToString(), "Długość klucza");
            }
            else
            {
                var resut = MessageBox.Show("Coś poszło nie tak, sprawdź wszystkie pola jeszcze raz.", "Błąd");
            }
        }
Exemple #4
0
 public geffe_step(lfsr _1, lfsr _2, lfsr _3)
 {
     lfsr1 = _1;
     lfsr2 = _2;
     lfsr3 = _3;
 }