Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //sync
            if (comboBox1.SelectedIndex == -1)
            {
                return;
            }
            ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex];

            if (CC.Publickey.Trim() == "")
            {
                if (MessageBox.Show("No publickey. Sync pubkey?", "Sync pubkey", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim())));
                    if (result.Trim() == "")
                    {
                        MessageBox.Show("ERROR");
                    }
                    else
                    {
                        String         pubkey = "<RSAKeyValue><Modulus>" + result + "</Exponent></RSAKeyValue>";
                        DataTable      tbl    = new DataTable();
                        SQLLiteconnect sql    = new SQLLiteconnect("db.db3");
                        sql.SQLTransact("UPDATE MyContacts SET publickey='" + DesClass.Encrypt(pubkey, pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'");
                        MessageBox.Show("OK");
                        LoadContacts();
                    }
                }
            }
            else
            {
                MessageBox.Show("<RSAKeyValue><Modulus>" + CC.Publickey.Trim() + "</Exponent></RSAKeyValue>");
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //save
            if (tbS1.Text.Trim() == "")
            {
                return;
            }
            if (tbP1.Text.Trim() == "")
            {
                return;
            }
            if (tbL1.Text.Trim() == "")
            {
                return;
            }
            if (tbW1.Text.Trim() == "")
            {
                return;
            }
            if (tbS2.Text.Trim() == "")
            {
                return;
            }
            if (tbP2.Text.Trim() == "")
            {
                return;
            }
            if (tbL2.Text.Trim() == "")
            {
                return;
            }
            if (tbW2.Text.Trim() == "")
            {
                return;
            }
            if (tbSite.Text.Trim() == "")
            {
                return;
            }

            SQLLiteconnect sql = new SQLLiteconnect("db.db3");

            sql.SQLTransact("Delete from MyMail");
            List <string> ListParam = new List <string>();

            ListParam.Add(DesClass.Encrypt(tbS1.Text.Trim(), pass));
            ListParam.Add(DesClass.Encrypt(tbS2.Text.Trim(), pass));
            ListParam.Add(DesClass.Encrypt(tbW1.Text.Trim(), pass));
            ListParam.Add(DesClass.Encrypt(tbW2.Text.Trim(), pass));
            ListParam.Add(DesClass.Encrypt(tbL1.Text.ToLower().Trim(), pass));
            ListParam.Add(DesClass.Encrypt(tbL2.Text.Trim(), pass));
            ListParam.Add(tbP1.Text.Trim());
            ListParam.Add(tbP2.Text.Trim());
            sql.SQLTransactParam("INSERT INTO MyMail (S1,S2,W1,W2,L1,L2,P1,P2,id) VALUES(?,?,?,?,?,?,?,?,0)", ListParam);

            sql.SQLTransact("UPDATE PubKeySite SET name='" + tbSite.Text.Trim() + "'");
            MessageBox.Show("OK");
            this.Close();
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            String contact = Microsoft.VisualBasic.Interaction.InputBox("Input Contact", "Contact", "", this.Location.X + 100, this.Location.Y + 100);

            if (contact.Trim() == "")
            {
                return;
            }
            DataTable      tbl = new DataTable();
            SQLLiteconnect sql = new SQLLiteconnect("db.db3");

            sql.SQLTransact("INSERT INTO MyContacts (name, publickey) VALUES('" + DesClass.Encrypt(contact.ToLower().Trim(), pass) + "','')");
            ListContact();
        }
Example #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            //save to base
            if (tbK1.Text.Trim() == "")
            {
                return;
            }
            if (tbK2.Text.Trim() == "")
            {
                return;
            }

            SQLLiteconnect sql = new SQLLiteconnect("db.db3");

            sql.SQLTransact("UPDATE MyTable SET pubkey='" + DesClass.Encrypt(tbK1.Text.Trim(), pass) + "', privkey='" + DesClass.Encrypt(tbK2.Text.Trim(), pass) + "'");
            MessageBox.Show("OK");
        }
Example #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (tbW3.Text.Trim().Length < 6)
            {
                MessageBox.Show("Error. Min length = 6"); return;
            }
            if (MessageBox.Show("Change your password?", "Change your password", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (tbS1.Text.Trim() == "")
                {
                    return;
                }
                if (tbP1.Text.Trim() == "")
                {
                    return;
                }
                if (tbL1.Text.Trim() == "")
                {
                    return;
                }
                if (tbW1.Text.Trim() == "")
                {
                    return;
                }
                if (tbS2.Text.Trim() == "")
                {
                    return;
                }
                if (tbP2.Text.Trim() == "")
                {
                    return;
                }
                if (tbL2.Text.Trim() == "")
                {
                    return;
                }
                if (tbW2.Text.Trim() == "")
                {
                    return;
                }
                if (tbSite.Text.Trim() == "")
                {
                    return;
                }

                SQLLiteconnect sql       = new SQLLiteconnect("db.db3");
                DataTable      tbl       = new DataTable();
                List <string>  ListParam = new List <string>();

                tbl = sql.SelectTable("select name, publickey from MyContacts");
                if (tbl.Rows.Count != 0)
                {
                    sql.SQLTransact("Delete from MyContacts");
                    for (int i = 0; i < tbl.Rows.Count; i++)
                    {
                        String pubkeycontact = DesClass.Decrypt(tbl.Rows[i][1].ToString().Trim(), pass);
                        String namecontact   = DesClass.Decrypt(tbl.Rows[i][0].ToString().Trim(), pass);
                        sql.SQLTransact("INSERT INTO MyContacts (name, publickey) VALUES('" + DesClass.Encrypt(namecontact, tbW3.Text.Trim()) + "','" + DesClass.Encrypt(pubkeycontact, tbW3.Text.Trim()) + "')");
                    }
                }

                String def = sha256(tbW3.Text.Trim());

                tbl = sql.SelectTable("select pubkey,privkey from MyTable");
                String pubkey  = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass);
                String privkey = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass);
                sql.SQLTransact("Delete from MyTable");

                sql.SQLTransactParam("INSERT INTO MyTable (pass,pubkey,privkey) VALUES('" + def + "','" + DesClass.Encrypt(pubkey, tbW3.Text.Trim()) + "','" + DesClass.Encrypt(privkey, tbW3.Text.Trim()) + "')", ListParam);

                pass = tbW3.Text.Trim();
                ListParam.Clear();
                sql.SQLTransact("Delete from MyMail");

                ListParam.Add(DesClass.Encrypt(tbS1.Text.Trim(), pass));
                ListParam.Add(DesClass.Encrypt(tbS2.Text.Trim(), pass));
                ListParam.Add(DesClass.Encrypt(tbW1.Text.Trim(), pass));
                ListParam.Add(DesClass.Encrypt(tbW2.Text.Trim(), pass));
                ListParam.Add(DesClass.Encrypt(tbL1.Text.ToLower().Trim(), pass));
                ListParam.Add(DesClass.Encrypt(tbL2.Text.Trim(), pass));
                ListParam.Add(tbP1.Text.Trim());
                ListParam.Add(tbP2.Text.Trim());
                sql.SQLTransactParam("INSERT INTO MyMail (S1,S2,W1,W2,L1,L2,P1,P2,id) VALUES(?,?,?,?,?,?,?,?,0)", ListParam);


                MessageBox.Show("Reopen application");
                Application.Exit();
            }
        }
Example #6
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }
            if (e.ClickedItem == contextMenuStrip1.Items[0])
            {
                //edit
                ContactClass CC      = (ContactClass)listBox1.Items[listBox1.SelectedIndex];
                String       contact = Microsoft.VisualBasic.Interaction.InputBox("Input Contact", "Contact", CC.Mail, this.Location.X + 100, this.Location.Y + 100);
                if (contact.Trim() == "")
                {
                    return;
                }
                DataTable      tbl = new DataTable();
                SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                sql.SQLTransact("UPDATE MyContacts SET name='" + DesClass.Encrypt(contact.ToLower().Trim(), pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'");
            }
            if (e.ClickedItem == contextMenuStrip1.Items[1])
            {
                //del
                if (MessageBox.Show("Delete the selected contact?", "Delete contact", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    ContactClass   CC  = (ContactClass)listBox1.Items[listBox1.SelectedIndex];
                    DataTable      tbl = new DataTable();
                    SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                    sql.SQLTransact("Delete from MyContacts where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'");
                }
            }
            if (e.ClickedItem == contextMenuStrip1.Items[4])
            {
                //sync
                ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex];

                String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim())));
                if (result.Trim() == "")
                {
                    MessageBox.Show("ERROR");
                }
                else
                {
                    String pubkey = "<RSAKeyValue><Modulus>" + result + "</Exponent></RSAKeyValue>";

                    //MessageBox.Show(pubkey);
                    DataTable      tbl = new DataTable();
                    SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                    sql.SQLTransact("UPDATE MyContacts SET publickey='" + DesClass.Encrypt(pubkey, pass) + "' where name='" + DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass) + "'");
                    MessageBox.Show("OK");
                }
            }

            if (e.ClickedItem == contextMenuStrip1.Items[2])
            {
                //create cryptomail
                ContactClass CC  = (ContactClass)listBox1.Items[listBox1.SelectedIndex];
                SendMailForm SMF = new SendMailForm(pass, CC.Mail.Trim(), "");
                SMF.ShowDialog();
            }

            if (e.ClickedItem == contextMenuStrip1.Items[3])
            {
                //show publickey
                ContactClass CC = (ContactClass)listBox1.Items[listBox1.SelectedIndex];
                if (CC.Publickey.Trim() == "")
                {
                    MessageBox.Show("No publickey");
                }
                else
                {
                    MessageBox.Show("<RSAKeyValue><Modulus>" + CC.Publickey.Trim() + "</Exponent></RSAKeyValue>");
                }
            }

            ListContact();
        }