Example #1
0
        /// <summary>
        /// Handles the TextChanged event of the TextMessage control.
        /// Handles the CheckBoxBase64_CheckedChanged control
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void TextMessage_TextChanged(object sender, EventArgs e)
        {
            if (StegEncode == null)
            {
                return;
            }

            if (StegEncode.PixelLoaded)
            {
                string text = TextMessage.Text;
                if (CheckBoxBase64.Checked)
                {
                    text = Converter.AsciiToBase64(text);
                }
                if (CheckBoxAes.Checked)
                {
                    text = Crypto.Encrypt(text, "filler");
                    if (text == null)
                    {
                        return;
                    }
                }
                int characters = (Constants.MessageLength * 8) + text.Length;
                LblCharacterCount.Text = String.Format("Characters: {0}/{1}", characters, StegEncode.MaxCharacters);
            }
        }
Example #2
0
        /// <summary>
        /// Handles the Click event of the BtnEncode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private async void BtnEncodeAsync_ClickAsync(object sender, EventArgs e)
        {
            if (!BtnEncodeReady())
            {
                return;
            }

            string message = TextMessage.Text;

            if (CheckBoxBase64.Checked)
            {
                message = Converter.AsciiToBase64(message);
            }

            if (CheckBoxAes.Checked)
            {
                message = Crypto.Encrypt(message, TextBoxAesKey.Text);
                if (message == null)
                {
                    MessageBox.Show(String.Format("{0} is not a valid hash type", Settings.Hash));
                    return;
                }
            }
            BtnEncode.Enabled = false;

            // Set up progress report
            TimerProgress.Start();
            ProgressBarEncode.Maximum = StegEncode.MaxCharacters * 8;
            ProgressBarEncode.Value   = 0;

            Task tEncode = new Task(() => StegEncode.CreateImage(message, StegEncode.OutputFile));

            tEncode.Start();
            await Task.WhenAll(tEncode);

            BtnEncode.Enabled       = true;
            ProgressBarEncode.Value = ProgressBarEncode.Maximum;
            TimerProgress.Stop();
        }