private void button6_Click(object sender, EventArgs e) { SystemInfo.SystemID SID = new SystemID(); string _systemID = SID.GetSystemID(); try { Steganography.HideData hd = new HideData(); Bitmap bmp = new Bitmap(_originalimagepath); encodedimage = hd.embedText(textBox6.Text, bmp, _systemID); encodedimage.Save(_encodedimagepath, System.Drawing.Imaging.ImageFormat.Bmp); MessageBox.Show("Image Saved Succesfully to\n" + _encodedimagepath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception a) { MessageBox.Show("This File is Encrypted.\nYou cannot Overwrite an encrypted file.", "Error Overwriting File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { if (_originalimagepath == null) { MessageBox.Show("Choose File to Extract Data", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { HideData hd = new HideData(); Bitmap _bmp = new Bitmap(_originalimagepath); textBox2.Text = hd.extractText(_bmp); } catch (Exception a) { DialogResult d = MessageBox.Show(a.Message, "Error decrypting file", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (d == DialogResult.OK) { if (a.Message == "This is an Password Encrypted Message.\nPress OK button to Enter the Password or Cancel to go back.") { int attempts = 0; while (attempts < 3) { try { Passwordform frm = new Passwordform(); frm.ShowDialog(); HideData hd = new HideData(); Bitmap _bmp = new Bitmap(_originalimagepath); textBox2.Text = hd.extractTextwithPassPhrase(_bmp, frm._password); break; } catch (Exception q) { attempts++; DialogResult w = MessageBox.Show(q.Message + "Note: After Invalid 3 Attempts, the data will be automatically Erased.\n Attempts Left:" + (3 - attempts), "Invalid Passphrase", MessageBoxButtons.RetryCancel, MessageBoxIcon.Stop); if (w != DialogResult.Retry) { break; } } } if (attempts >= 3) { MessageBox.Show("You have reached maximum number of attempts.\nExiting Application..", "Invalid Attempts", MessageBoxButtons.OK, MessageBoxIcon.Error); Thread.Sleep(1000); Application.Exit(); } } else if (a.Message == "This is an Single System Encrypted Message.\nIf you believe this message has been created for your system, try decoding this image from 'Encrypt Message' tab.") { try { SystemInfo.SystemID SID = new SystemID(); HideData hd = new HideData(); Bitmap _bmp = new Bitmap(_originalimagepath); textBox2.Text = hd.extractText(_bmp, SID.GetSystemID()); } catch (Exception w) { MessageBox.Show(w.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } }