示例#1
0
        /*
         * Incapsulate logic of calculating
         * timing of syncronized constructor
         */
        private TimeSpan GetTimeOfSyncConstructor(int keyLength)
        {
            Task <TimeSpan> syncRSATimeCounterTask = new Task <TimeSpan>(() => {
                return(RSACryptor.TimeOfRSASynchronizedConstructor(keyLength));
            });

            syncRSATimeCounterTask.Start();
            syncRSATimeCounterTask.Wait();
            return(syncRSATimeCounterTask.Result);
        }
示例#2
0
        /*
         * This click activate RSACryptor that generates values
         * and forms initialize by this values, also in this method
         * added features with calculating time of 2 rsa constructors :
         *      one threaded(syncronized)
         *      multy threaded(asyncronized)
         * and showing report about this
         */
        private void generateKeysButton_Click(object sender, EventArgs e)
        {
            int keyLength;

            try
            {
                keyLength = int.Parse(keyLengthInput.Text);
            }
            catch
            {
                MessageBox.Show("Input keylength!");
                return;
            }

            if (keyLength < 64)
            {
                MessageBox.Show("Length of key should be more than 63!");
                return;
            }

            Stopwatch timer = new Stopwatch();

            timer.Start();
            cryptor = new RSACryptor(keyLength);
            timer.Stop();

            pIO.Text = cryptor.P.ToString();
            qIO.Text = cryptor.Q.ToString();

            NOutput.Text             = cryptor.N.ToString();
            eulerFunctionOutput.Text = cryptor.EulerValue.ToString();
            eOutput.Text             = cryptor.E.ToString();
            dOutput.Text             = cryptor.D.ToString();

            MessageBox.Show("Start calculating sync constructor");

            TimeSpan rsaSyncTime = GetTimeOfSyncConstructor(keyLength);
            string   timeReport  = GetTimeReport(timer.Elapsed, rsaSyncTime);

            MessageBox.Show(timeReport);
        }