private void btnPlay_Click(object sender, EventArgs e) { if (!this._initialized) { if (!this.Initialize()) { return; } this._initialized = true; } if (this._initialized && !this._isPlaying) { if (this._message != null) { this._message.Dispose(); } RC4 rc4 = new RC4(this.txt_keyLive.Text, this.rtxt_liveMessage.Text); this._message = new HideIt.Stego.Message(this.txt_keyLive.Text, rc4.ApplyRC4()); this._liveProcessor.StartCapturing(this._message, this.cb_stopAutomatically.Checked); this._isPlaying = true; } ///data inserrtion to maintain log table string _stego_file_name = txt_saveCapturedPath.Text; string _key = txt_keyLive.Text; string _time = DateTime.Now.ToLongTimeString(); string _date = DateTime.Now.ToShortDateString(); SqlConnection conn = new SqlConnection(DB.DbConnectionStr.conect()); SqlCommand query = new SqlCommand("insert into Log_Table values('" + _stego_file_name + "','" + _key + "', '" + _date + "', '" + _time + "')", conn); try { conn.Open(); query.ExecuteNonQuery(); ///MessageBox.Show("Record entered successfully."); conn.Close(); } catch (SqlException ex) { MessageBox.Show("Exception Accured" + ex, "Window Warning"); } }
/// <summary> /// Called when new task is registered with background worker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorkerArgs args = e.Argument as BackgroundWorkerArgs; ///Set the result to args that will be used when operations completes e.Result = args; if (args != null) { switch (args.Action) { case ActionType.Hide: //User has entered a save path for stego object, start hiding using (Status status = new Status(this, this.lbl_status, "Hidding...")) { RC4 encrypt = new RC4(args.Message.Key, args.Message.SecertMessage); HideIt.Stego.Message message = new HideIt.Stego.Message( args.Message.Key, encrypt.ApplyRC4()); using (LockUI lockUi = new LockUI(this)) { this._processor.Hide(message, args.SinkPath); //"hide" tab selected } } break; case ActionType.Extract: using (Status status = new Status(this, this.lbl_status, "Extracting...")) { using (LockUI lockUi = new LockUI(this)) { args.Message = this._processor.Extract(args.Key); //"extract" tab selected } } if (args.Message == null) { UIMessage.Info("Cannot extract message from stego object because of one of the following reasons:\r\n" + "-Stego object do no contain any message\r\n" + "-Key provided do not match with the key used to hide message", "Extract Message"); return; } RC4 decrypt = new RC4(args.Key, args.Message.SecertMessage); if (this.rtxt_hiddenMsg.InvokeRequired) { this.rtxt_hiddenMsg.Invoke((MethodInvoker)(() => { this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4(); })); } else { this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4(); } break; } } }