Esempio n. 1
0
 private void passwordMenuItem_Click(object sender, EventArgs e)
 {
     if (asciiPasswordMenuItem.Checked)
     {
         using (PasswordForm form = new PasswordForm())
         {
             if (password != null)
             {
                 form.textBox.Text = Encoding.GetEncoding("GB2312").GetString(password);
             }
             if (form.ShowDialog() == DialogResult.OK)
             {
                 password = Encoding.GetEncoding("GB2312").GetBytes(form.textBox.Text);
                 PasswordToKey();
             }
         }
     }
     else if (unicodePasswordMenuItem.Checked)
     {
         using (PasswordForm form = new PasswordForm())
         {
             if (password != null)
             {
                 form.textBox.Text = Encoding.Unicode.GetString(password);
             }
             if (form.ShowDialog() == DialogResult.OK)
             {
                 password = Encoding.Unicode.GetBytes(form.textBox.Text);
                 PasswordToKey();
             }
         }
     }
     else
     {
         using (HexForm form = new HexForm())
         {
             form.Text = "密码";
             if ("RSA" == GetAsymmetricName())
             {
                 form.publicKey  = publicKey;
                 form.privateKey = privateKey;
             }
             if (password != null)
             {
                 form.byteViewer.SetBytes(password);
             }
             if (form.ShowDialog() == DialogResult.OK)
             {
                 password = form.byteViewer.GetBytes();
                 PasswordToKey();
             }
         }
     }
 }
Esempio n. 2
0
 private void keyMenuItem_Click(object sender, EventArgs e)
 {
     using (HexForm form = new HexForm())
     {
         form.Text = "密钥";
         if ("RSA" == GetAsymmetricName())
         {
             form.publicKey  = publicKey;
             form.privateKey = privateKey;
         }
         if (key != null)
         {
             form.byteViewer.SetBytes(key);
         }
         if (form.ShowDialog() == DialogResult.OK)
         {
             key = form.byteViewer.GetBytes();
         }
     }
 }