Ejemplo n.º 1
0
        private void btPublic_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title  = "Select public key file";
                ofd.Filter = "Txt|*.txt|Doc|*.docx|All|*.*";
                ofd.ShowDialog();
                try
                {
                    string                   fullPath  = ofd.FileName;
                    StreamReader             readerObj = new StreamReader(File.Open(fullPath, FileMode.Open));
                    RSACryptoServiceProvider rsaTmp    = new RSACryptoServiceProvider();

                    rsaTmp.FromXmlString(readerObj.ReadToEnd());

                    mainGen = new Gen_Rec();
                    mainGen.importPublicKey(rsaTmp);

                    readerObj.Close();

                    //mainGen.mainRSA.FromXmlString(readerObj.ReadToEnd());
                    // Se nao ocorrer erros, imprima que a importação ocorreu com sucesso!
                    MessageBox.Show("Public key was imported successfully.", "Warning");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Error : " + exc.Message, "Error");
                }
            }
        }
Ejemplo n.º 2
0
        public GenerateKey(Gen_Rec rcvGen)
        {
            InitializeComponent();
            persistencia = rcvGen;
            try
            {
                if (rcvGen.mainRSA.KeySize > 1)
                {
                    // significa que há chaves geradas ja
                    tbPublic.Text  = rcvGen.mainRSA.ToXmlString(false);
                    tbPrivate.Text = rcvGen.mainRSA.ToXmlString(true);

                    btCopiar.Enabled         = true;
                    btCopiarPrivada.Enabled  = true;
                    btSalvarComoPub.Enabled  = true;
                    btSalvarComoPriv.Enabled = true;
                }
            }
            catch
            {
            }
            finally
            {
                cbLenght.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        public MyKeys(Gen_Rec mainGen)
        {
            InitializeComponent();

            try
            {
                if (mainGen.mainRSA.ToXmlString(false).Length > 0)
                {
                    tbPublic.Text = mainGen.mainRSA.ToXmlString(false);
                }
            }
            catch
            {
                tbPublic.Text = "";
            }


            try
            {
                if (mainGen.mainRSA.ToXmlString(true).Length > 0)
                {
                    tbPrivate.Text = mainGen.mainRSA.ToXmlString(true);
                }
            }
            catch
            {
                tbPrivate.Text = "";
            }

            this.mainGen = mainGen;
        }
Ejemplo n.º 4
0
        private void btGenerate_Click(object sender, EventArgs e)
        {
            GenerateKey obj = new GenerateKey(mainGen);

            this.Hide();
            obj.ShowDialog();
            mainGen = obj.ReturnGen();
            this.Show();
        }
Ejemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            // OBJETO MAIS IMPORTANTE.
            mainRSA        = new RSACryptoServiceProvider(Int32.Parse(cbLenght.SelectedItem.ToString()));
            persistencia   = new Gen_Rec(mainRSA);
            tbPublic.Text  = persistencia.publicKey;
            tbPrivate.Text = persistencia.privateKey;

            btCopiar.Enabled         = true;
            btCopiarPrivada.Enabled  = true;
            btSalvarComoPub.Enabled  = true;
            btSalvarComoPriv.Enabled = true;
        }
Ejemplo n.º 6
0
 public Descriptografar(Gen_Rec obj)
 {
     InitializeComponent();
     this.obj = obj;
 }
Ejemplo n.º 7
0
 public Criptografar(Gen_Rec obj)
 {
     InitializeComponent();
     main_gen = obj;
 }