コード例 #1
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();
        }
コード例 #2
0
ファイル: SendMailForm.cs プロジェクト: karamush/Cryptomail
        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>");
            }
        }
コード例 #3
0
ファイル: FormSavePubkey.cs プロジェクト: Khanzo/Cryptomail
 private void button2_Click(object sender, EventArgs e)
 {
     String pubkey = richTextBox1.Text;
     DataTable tbl = new DataTable();
     SQLLiteconnect sql = new SQLLiteconnect("db.db3");
     sql.SQLTransact("UPDATE MyContacts SET publickey='" + DesClass.Encrypt(pubkey, pass) + "' where name='" + contact + "'");
     MessageBox.Show("OK");
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: karamush/Cryptomail
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "") { return; }

            if (File.Exists("db.db3") == false)
            {
                String def = sha256("123456");
                SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                sql.SQLTransact("CREATE TABLE MyTable (pass String, pubkey String, privkey String)");
                sql.SQLTransact("CREATE TABLE MyContacts (name String, publickey String)");
                sql.SQLTransact("CREATE TABLE PubKeySite (name String)");
                sql.SQLTransact("INSERT INTO MyTable (pass,pubkey,privkey) VALUES('" + def +"','','')");
                sql.SQLTransact("CREATE TABLE MyMail(S1 String, P1 String, W1 String, L1 String, S2 String, P2 String, W2 String, L2 String,id Int)");
                sql.SQLTransact("INSERT INTO MyMail (S1,S2,W1,W2,L1,L2,P1,P2,id) VALUES('','','','','','','993','25',0)");
                sql.SQLTransact("INSERT INTO PubKeySite (name) VALUES('http://localhost:8080')");

            }
            else
            {
                String def = sha256(textBox1.Text.Trim());
                DataTable tbl = new DataTable();
                SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                tbl= sql.SelectTable("select * from MyTable where pass='******'");
                if (tbl.Rows.Count == 0) { return; }

            }

            FormMain FM = new FormMain(textBox1.Text.Trim());
            FM.FormClosed += FM_FormClosed;
            this.Hide();
            FM.Show();
        }
コード例 #5
0
ファイル: ContactsForm.cs プロジェクト: karamush/Cryptomail
 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();
 }
コード例 #6
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();
        }
コード例 #7
0
ファイル: RSAForm.cs プロジェクト: karamush/Cryptomail
        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");
        }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "")
            {
                return;
            }

            if (File.Exists("db.db3") == false)
            {
                String         def = sha256("123456");
                SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                sql.SQLTransact("CREATE TABLE MyTable (pass String, pubkey String, privkey String)");
                sql.SQLTransact("CREATE TABLE MyContacts (name String, publickey String)");
                sql.SQLTransact("CREATE TABLE PubKeySite (name String)");
                sql.SQLTransact("INSERT INTO MyTable (pass,pubkey,privkey) VALUES('" + def + "','','')");
                sql.SQLTransact("CREATE TABLE MyMail(S1 String, P1 String, W1 String, L1 String, S2 String, P2 String, W2 String, L2 String,id Int)");
                sql.SQLTransact("INSERT INTO MyMail (S1,S2,W1,W2,L1,L2,P1,P2,id) VALUES('','','','','','','993','25',0)");
                sql.SQLTransact("INSERT INTO PubKeySite (name) VALUES('http://localhost:8080')");
            }
            else
            {
                String         def = sha256(textBox1.Text.Trim());
                DataTable      tbl = new DataTable();
                SQLLiteconnect sql = new SQLLiteconnect("db.db3");
                tbl = sql.SelectTable("select * from MyTable where pass='******'");
                if (tbl.Rows.Count == 0)
                {
                    return;
                }
            }


            FormMain FM = new FormMain(textBox1.Text.Trim());

            FM.FormClosed += FM_FormClosed;
            this.Hide();
            FM.Show();
        }
コード例 #9
0
ファイル: SendMailForm.cs プロジェクト: Khanzo/Cryptomail
        private void button2_Click(object sender, EventArgs e)
        {
            //sync
            if (comboBox1.SelectedIndex == -1) { return; }
            int sel = comboBox1.SelectedIndex;
            ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex];

            if (CC.Publickey.Trim() == "") {

                if (MessageBox.Show(line3,line4, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    String result = DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(CC.Mail.ToLower().Trim())));
                    if (result.Trim() == "")
                    {
                        MessageBox.Show(line5);
                    }
                    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();
                        comboBox1.SelectedIndex = sel;
                    }

                }

            }
            else
            {

                FormSavePubkey SMF = new FormSavePubkey(CC.Publickey.Trim(), pass, DesClass.Encrypt(CC.Mail.ToLower().Trim(), pass));
                SMF.Text = CC.Mail.ToLower().Trim() + " :: Contact Public key";
                SMF.ShowDialog();

                LoadContacts();
                comboBox1.SelectedIndex = sel;
            }
        }
コード例 #10
0
ファイル: RSAForm.cs プロジェクト: Khanzo/Cryptomail
        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");
        }
コード例 #11
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();
            }
        }
コード例 #12
0
ファイル: FormOptions.cs プロジェクト: karamush/Cryptomail
        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();
        }
コード例 #13
0
ファイル: FormOptions.cs プロジェクト: karamush/Cryptomail
        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();
            }
        }
コード例 #14
0
ファイル: ContactsForm.cs プロジェクト: karamush/Cryptomail
        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();
        }
コード例 #15
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();
        }