示例#1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     using (var Keygen = new frmRsaGen())
     {
         if (Keygen.ShowDialog() == DialogResult.OK)
         {
             var Props = new { Keygen.KeyName, Keygen.KeySize };
             foreach (var C in Controls)
             {
                 ((Control)C).Enabled = false;
             }
             pbGenerator.Visible = true;
             Thread T = new Thread(delegate()
             {
                 var Key = RSAEncryption.GenerateKey(Props.KeyName, Props.KeySize);
                 Invoke((MethodInvoker) delegate
                 {
                     var Keys = Settings.LoadRSAKeys().ToList();
                     Keys.Add(Key);
                     foreach (var C in Controls)
                     {
                         ((Control)C).Enabled = true;
                     }
                     pbGenerator.Visible = false;
                     Settings.SaveRSAKeys(Keys, true);
                     InitRSA();
                 });
             });
             T.IsBackground = true;
             T.Start();
         }
     }
 }
示例#2
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     using (var F = new frmRsaGen())
     {
         if (F.ShowDialog() == DialogResult.OK)
         {
             var Props = new { F.KeyName, F.KeySize };
             foreach (var C in Controls)
             {
                 ((Control)C).Enabled = false;
             }
             pbKeygen.Visible = true;
             Thread T = new Thread(delegate()
             {
                 var Key = RSAEncryption.GenerateKey(Props.KeyName, Props.KeySize);
                 AllKeys.Add(Key);
                 Invoke((MethodInvoker) delegate
                 {
                     foreach (var C in Controls)
                     {
                         ((Control)C).Enabled = true;
                     }
                     pbKeygen.Visible = false;
                     InitList(Key);
                 });
             });
             T.IsBackground = true;
             T.Start();
         }
     }
 }