private void button2_Click(object sender, EventArgs e) { //send to server if (tbK1.Text.Trim() == "") { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select L1 from MyMail"); String mail = ""; if (tbl.Rows[0][0].ToString().Trim().Length > 0) { mail = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (mail == "") { return; } String pubkey = tbK1.Text.Trim().Replace("<RSAKeyValue><Modulus>", ""); pubkey = pubkey.Trim().Replace("</Exponent></RSAKeyValue>", ""); String result = ServerAPIClass.SendPubKey(DesClass.Encode(mail), DesClass.Encode(pubkey)); // tbK2.Text = "<RSAKeyValue><Modulus>" + DesClass.Decode(ServerAPIClass.ReadPubKey(DesClass.Encode(mail), "http://localhost:8080")) + "</Exponent></RSAKeyValue>"; if (result.Trim() == "OK") { MessageBox.Show("OK"); } else { MessageBox.Show("ERROR"); } }
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(); }
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>"); } }
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(); }
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"); }
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(); }
private void button1_Click(object sender, EventArgs e)//load header mail { if (date1.Value > date2.Value) { MessageBox.Show("ERROR period."); return; } sb = new StringBuilder(); DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { S1 = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { S2 = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][2].ToString().Trim().Length > 0) { W1 = DesClass.Decrypt(tbl.Rows[0][2].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { W2 = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { L1 = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { L2 = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } P1 = tbl.Rows[0][6].ToString(); P2 = tbl.Rows[0][7].ToString(); if (S1 == "") { MessageBox.Show("Options failed"); return; } Loadheader(); }
public FormReg() { InitializeComponent(); string site = "http://localhost:8080"; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { site = tbl.Rows[0][0].ToString().Trim(); } webBrowser1.Navigate(site); }
public static string SendPubKey(string email, string pubkey)//отправляем pubkey { string site = "http://localhost:8080"; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { site = tbl.Rows[0][0].ToString().Trim(); } string result = ""; string url = site + "/sendpubkey.php"; WebResponse response = null; System.IO.StreamReader reader = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; string postData = "mail=" + email + "&pubkey=" + pubkey; byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); response = request.GetResponse(); reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); result = reader.ReadToEnd(); } catch { } finally { if (reader != null) { reader.Close(); } if (response != null) { response.Close(); } } return(result); }
public FormOptions(String Pass) { InitializeComponent(); pass = Pass; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbS1.Text = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { tbS2.Text = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][2].ToString().Trim().Length > 0) { tbW1.Text = DesClass.Decrypt(tbl.Rows[0][2].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { tbW2.Text = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { tbL1.Text = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { tbL2.Text = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } tbP1.Text = tbl.Rows[0][6].ToString(); tbP2.Text = tbl.Rows[0][7].ToString(); tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbSite.Text = tbl.Rows[0][0].ToString().Trim(); } }
public RSAForm(String Pass) { InitializeComponent(); pass = Pass; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select pubkey, privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbK1.Text = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { tbK2.Text = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } try{ //----lang load string selectLang = "en-EN"; if (System.IO.File.Exists(@"lang.cfg")) { string[] lines = System.IO.File.ReadAllLines(@"lang.cfg"); selectLang = lines[0]; } if (selectLang != "en-EN") { string AssemblyName = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName; string pt = Path.GetDirectoryName(AssemblyName); string path = pt + @"\lang\" + selectLang.Trim() + ".lng"; if (System.IO.File.Exists(path)) { string[] lines = System.IO.File.ReadAllLines(path);//--load button1.Text = lines[34]; button3.Text = lines[9]; button2.Text = lines[35]; button4.Text = lines[11]; button5.Text = lines[36]; button6.Text = lines[49]; line1 = lines[25]; } } } catch { MessageBox.Show("Error loading language file!"); } }
public FormOptions(String Pass) { InitializeComponent(); pass = Pass; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); if (tbl.Rows[0][0].ToString().Trim().Length>0) { tbS1.Text = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { tbS2.Text = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][2].ToString().Trim().Length > 0) { tbW1.Text = DesClass.Decrypt(tbl.Rows[0][2].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { tbW2.Text = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { tbL1.Text = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { tbL2.Text = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } tbP1.Text = tbl.Rows[0][6].ToString(); tbP2.Text = tbl.Rows[0][7].ToString(); tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbSite.Text = tbl.Rows[0][0].ToString().Trim(); } }
public RSAForm(String Pass) { InitializeComponent(); pass = Pass; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select pubkey, privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbK1.Text = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { tbK2.Text = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } }
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"); }
public void ListContact() { listBox1.Items.Clear(); DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select name, publickey from MyContacts"); if (tbl.Rows.Count != 0) { for (int i = 0; i < tbl.Rows.Count; i++) { ContactClass CC = new ContactClass(); CC.Mail = DesClass.Decrypt(tbl.Rows[i][0].ToString().Trim(), pass); CC.Publickey = DesClass.Decrypt(tbl.Rows[i][1].ToString().Trim(), pass); listBox1.DisplayMember = "Mail"; listBox1.Items.Add(CC); } } }
//отправляем pubkey public static string SendPubKey(string email, string pubkey) { string site = "http://localhost:8080"; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { site = tbl.Rows[0][0].ToString().Trim(); } string result = ""; string url = site+"/sendpubkey.php"; WebResponse response = null; System.IO.StreamReader reader = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; string postData = "mail=" + email + "&pubkey=" + pubkey; byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); response = request.GetResponse(); reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); result = reader.ReadToEnd(); } catch { } finally { if (reader != null) reader.Close(); if (response != null) response.Close(); } return result; }
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(); }
//загрузка контактов private void LoadContacts() { comboBox1.Items.Clear(); DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select pubkey from MyTable"); String privKey = ""; if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } ContactClass CC1 = new ContactClass(); CC1.Mail = line4; CC1.Publickey = privKey; comboBox1.DisplayMember = "Mail"; comboBox1.Items.Add(CC1); tbl = sql.SelectTable("select name, publickey from MyContacts"); if (tbl.Rows.Count != 0) { for (int i = 0; i < tbl.Rows.Count; i++) { ContactClass CC = new ContactClass(); CC.Mail = DesClass.Decrypt(tbl.Rows[i][0].ToString().Trim(), pass); CC.Publickey = DesClass.Decrypt(tbl.Rows[i][1].ToString().Trim(), pass); comboBox1.DisplayMember = "Mail"; comboBox1.Items.Add(CC); } } comboBox1.SelectedIndex = 0; }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (listBox1.SelectedIndex == -1) { return; } if (e.ClickedItem == contextMenuStrip1.Items[0])//read body mail { //answer if (listBox1.SelectedIndex == -1) { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } int k = 0; MailObjClass MO = (MailObjClass)listBox1.Items[listBox1.SelectedIndex]; richTextBox1.Clear(); richTextBox1.Text += "From: " + MO.Mailfrom + "\r\n"; richTextBox1.Text += "Date: " + MO.Datesend + "\r\n"; richTextBox1.Text += "\r\n"; t = true; sb = new StringBuilder(); ReadCryptoMail(Convert.ToInt32(MO.Nummail)); String bodymail2 = ""; String bodymail = sb.ToString(); //richTextBox2.Text = sb.ToString(); while (bodymail.IndexOf("=") > 0) { k = bodymail.IndexOf("=="); if (k <= 0) { k = bodymail.IndexOf("="); if (k > 0) { bodymail2 = bodymail.Substring(0, k + 1); bodymail = bodymail.Remove(0, k + 1); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } else { bodymail2 = bodymail.Substring(0, k + 2); bodymail = bodymail.Remove(0, k + 2); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } //----------------bodymail; SendMailForm SMF = new SendMailForm(pass, MO.Mailfrom, MO.Datesend + "\r\n" + richTextBox1.Text); SMF.ShowDialog(); } }
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(); }
public FormOptions(String Pass) { InitializeComponent(); pass = Pass; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2,SID from MyMail"); if (tbl.Rows.Count > 0) { if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbS1.Text = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { tbS2.Text = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][2].ToString().Trim().Length > 0) { tbW1.Text = DesClass.Decrypt(tbl.Rows[0][2].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { tbW2.Text = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { tbL1.Text = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { tbL2.Text = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } tbP1.Text = tbl.Rows[0][6].ToString(); tbP2.Text = tbl.Rows[0][7].ToString(); if (tbl.Rows[0][8].ToString().Trim().Length > 0) { tbSID.Text = tbl.Rows[0][8].ToString().Trim(); } tbl = sql.SelectTable("select name from PubKeySite"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { tbSite.Text = tbl.Rows[0][0].ToString().Trim(); } } string[] files = GetFiles(); string selectLang = "en-EN"; int i = 0; try{ //----lang load if (System.IO.File.Exists(@"lang.cfg")) { string[] lines = System.IO.File.ReadAllLines(@"lang.cfg"); selectLang = lines[0]; } cbLang.Items.Add("en-EN"); foreach (string file in files) { string[] nam = file.Split('.'); cbLang.Items.Add(nam[0]); if (nam[0].IndexOf(selectLang.Trim()) == 0) { i = cbLang.Items.Count - 1; } } } catch { MessageBox.Show("Error loading language file!"); } cbLang.SelectedIndex = i; //---------------lang //----lang load /* string selectLang = "en-EN"; if (System.IO.File.Exists(@"lang.cfg")) { string[] lines = System.IO.File.ReadAllLines(@"lang.cfg"); selectLang = lines[0]; }*/ if (selectLang != "en-EN") { string AssemblyName = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName; string pt = Path.GetDirectoryName(AssemblyName); string path = pt + @"\lang\" + selectLang.Trim()+".lng"; if (System.IO.File.Exists(path)) { string[] lines = System.IO.File.ReadAllLines(path);//--load label1.Text = lines[0]; label4.Text = lines[1]; label2.Text = lines[2]; label6.Text = lines[2]; label3.Text = lines[3]; label5.Text = lines[3]; label7.Text = lines[4]; label8.Text = lines[4]; label10.Text = lines[5]; label11.Text = lines[6]; label9.Text = lines[7]; label12.Text = lines[8]; button1.Text = lines[9]; button3.Text = lines[10]; button2.Text = lines[11]; button4.Text = lines[12]; line1 = lines[13]; line2 = lines[14]; line3 = lines[15]; line4 = lines[16]; } } }
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(); } }
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(); }
private void button2_Click(object sender, EventArgs e) { try{ String bodymail = rtbEnc.Text.ToString(); String bodymail2 = ""; DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select privkey from MyTable"); String privKey = ""; if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } rtbDec.Text = ""; int k = 0; while (bodymail.IndexOf("=") > 0) { k = bodymail.IndexOf("=="); if (k <= 0) { k = bodymail.IndexOf("="); if (k > 0) { bodymail2 = bodymail.Substring(0, k + 1); bodymail = bodymail.Remove(0, k + 1); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } rtbDec.Text += DesClass.RSADec(part, privKey); } } } else { bodymail2 = bodymail.Substring(0, k + 2); bodymail = bodymail.Remove(0, k + 2); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } rtbDec.Text += DesClass.RSADec(part, privKey); } } } } catch { MessageBox.Show(line5); } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (listBox1.SelectedIndex == -1) { return; } if (e.ClickedItem == contextMenuStrip1.Items[0])//read body mail { //answer if (listBox1.SelectedIndex == -1) { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } int k = 0; MailObjClass MO = (MailObjClass)listBox1.Items[listBox1.SelectedIndex]; richTextBox1.Clear(); richTextBox1.Text += "From: " + MO.Mailfrom + "\r\n"; richTextBox1.Text += "Date: " + MO.Datesend + "\r\n"; richTextBox1.Text += "\r\n"; t = true; sb = new StringBuilder(); ReadCryptoMail(Convert.ToInt32(MO.Nummail)); String bodymail2 = ""; String bodymail = sb.ToString(); //richTextBox2.Text = sb.ToString(); try{ while (bodymail.IndexOf("=") > 0) { k = bodymail.IndexOf("=="); if (k <= 0) { k = bodymail.IndexOf("="); if (k > 0) { bodymail2 = bodymail.Substring(0, k + 1); bodymail = bodymail.Remove(0, k + 1); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } else { bodymail2 = bodymail.Substring(0, k + 2); bodymail = bodymail.Remove(0, k + 2); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } //----------------bodymail; SendMailForm SMF = new SendMailForm(pass, MO.Mailfrom, MO.Datesend + "\r\n" + richTextBox1.Text); SMF.ShowDialog(); } catch { MessageBox.Show(line1); } } }
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; } }
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(); } }
//load header mail private void button1_Click(object sender, EventArgs e) { if (date1.Value > date2.Value) { MessageBox.Show("ERROR period."); return; } sb = new StringBuilder(); DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { S1 = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } if (tbl.Rows[0][1].ToString().Trim().Length > 0) { S2 = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][2].ToString().Trim().Length > 0) { W1 = DesClass.Decrypt(tbl.Rows[0][2].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { W2 = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { L1 = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { L2 = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } P1 = tbl.Rows[0][6].ToString(); P2 = tbl.Rows[0][7].ToString(); if (S1 == "") { MessageBox.Show("Options failed"); return; } Loadheader(); }
private void button1_Click(object sender, EventArgs e) { //send if (comboBox1.SelectedIndex == -1) { return; } ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex]; if (CC.Publickey.Trim() == "") { MessageBox.Show("No publickey"); return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); String S2 = ""; String L1 = ""; String L2 = ""; String W2 = ""; String P2 = ""; if (tbl.Rows[0][1].ToString().Trim().Length > 0) { S2 = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { W2 = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { L1 = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { L2 = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } P2 = tbl.Rows[0][7].ToString(); if (S2 == "") { MessageBox.Show("Options failed"); return; } if (W2 == "") { MessageBox.Show("Options failed"); return; } if (P2 == "") { MessageBox.Show("Options failed"); return; } if (L1 == "") { MessageBox.Show("Options failed"); return; } var fromAddress = new MailAddress(L1.Trim(), ""); string fromPassword = W2.Trim(); var toAddress = new MailAddress(CC.Mail.Trim(), ""); const string subject = "Cryptomail"; richTextBox1.Text += "**************************************************************************************"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < richTextBox1.Text.Length; i++) { sb.Append(DesClass.RSAEnc(richTextBox1.Text.Substring(0, 40), CC.Publickey)); richTextBox1.Text = richTextBox1.Text.Remove(0, 40); if (richTextBox1.Text.Length <= 40) { sb.Append(DesClass.RSAEnc(richTextBox1.Text, CC.Publickey)); break; } } var smtp = new SmtpClient { Host = S2.Trim(), Port = Convert.ToInt32(P2.Trim()), EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = sb.ToString(), }) { // message.Headers.Add("X-Message-Flag", "Flagged"); smtp.Send(message); } richTextBox1.Text = ""; MessageBox.Show("OK"); }
private void button1_Click(object sender, EventArgs e) { //send if (comboBox1.SelectedIndex == -1) { return; } ContactClass CC = (ContactClass)comboBox1.Items[comboBox1.SelectedIndex]; if (CC.Publickey.Trim() == "") { MessageBox.Show(line1); return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select S1,S2,W1,W2,L1,L2,P1,P2 from MyMail"); String S2 = ""; String L1 = ""; String L2 = ""; String W2 = ""; String P2 = ""; if (tbl.Rows[0][1].ToString().Trim().Length > 0) { S2 = DesClass.Decrypt(tbl.Rows[0][1].ToString().Trim(), pass); } if (tbl.Rows[0][3].ToString().Trim().Length > 0) { W2 = DesClass.Decrypt(tbl.Rows[0][3].ToString().Trim(), pass); } if (tbl.Rows[0][4].ToString().Trim().Length > 0) { L1 = DesClass.Decrypt(tbl.Rows[0][4].ToString().Trim(), pass); } if (tbl.Rows[0][5].ToString().Trim().Length > 0) { L2 = DesClass.Decrypt(tbl.Rows[0][5].ToString().Trim(), pass); } P2 = tbl.Rows[0][7].ToString(); if (S2 == "") { MessageBox.Show(line2); return; } if (W2 == "") { MessageBox.Show(line2); return; } if (P2 == "") { MessageBox.Show(line2); return; } if (L1 == "") { MessageBox.Show(line2); return; } var fromAddress = new MailAddress(L1.Trim(), ""); string fromPassword = W2.Trim(); var toAddress = new MailAddress(CC.Mail.Trim(), ""); const string subject = "Cryptomail"; richTextBox1.Text+="**************************************************************************************"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < richTextBox1.Text.Length; i++) { sb.Append(DesClass.RSAEnc(richTextBox1.Text.Substring(0, 40), CC.Publickey)); richTextBox1.Text = richTextBox1.Text.Remove(0, 40); if (richTextBox1.Text.Length <= 40) { sb.Append(DesClass.RSAEnc(richTextBox1.Text, CC.Publickey)); break; } } var smtp = new SmtpClient { Host = S2.Trim(), Port = Convert.ToInt32(P2.Trim()), EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = sb.ToString(), }) { // message.Headers.Add("X-Message-Flag", "Flagged"); smtp.Send(message); } richTextBox1.Text = ""; MessageBox.Show("OK"); }
//read body mail private void listBox1_DoubleClick(object sender, EventArgs e) { //select from if (listBox1.SelectedIndex == -1) { return; } DataTable tbl = new DataTable(); SQLLiteconnect sql = new SQLLiteconnect("db.db3"); tbl = sql.SelectTable("select privkey from MyTable"); if (tbl.Rows[0][0].ToString().Trim().Length > 0) { privKey = DesClass.Decrypt(tbl.Rows[0][0].ToString().Trim(), pass); } int k = 0; MailObjClass MO = (MailObjClass)listBox1.Items[listBox1.SelectedIndex]; richTextBox1.Clear(); richTextBox1.Text += "From: " + MO.Mailfrom + "\r\n"; richTextBox1.Text += "Date: " + MO.Datesend + "\r\n"; richTextBox1.Text += "\r\n"; t = true; sb = new StringBuilder(); ReadCryptoMail(Convert.ToInt32(MO.Nummail)); String bodymail2 = ""; String bodymail = sb.ToString(); //richTextBox2.Text = sb.ToString(); while (bodymail.IndexOf("=") > 0) { k = bodymail.IndexOf("=="); if (k <= 0) { k = bodymail.IndexOf("="); if (k > 0) { bodymail2 = bodymail.Substring(0, k + 1) ; bodymail = bodymail.Remove(0, k + 1); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } else { bodymail2 = bodymail.Substring(0, k + 2); bodymail = bodymail.Remove(0, k + 2); if (bodymail2.Length > 3) { // MessageBox.Show(Parts[i]); String part = bodymail2.Replace(".", ""); if (part.IndexOf("3D") == 0) { part = part.Remove(0, 2); } richTextBox1.Text += DesClass.RSADec(part, privKey); } } } //----------------bodymail; }