예제 #1
0
        private void RefreshRequiredSize()
        {
            Trithemius t = new Trithemius(null);
            t.LeastSignificantBits = (int)bitsNumericUpDown.Value;

            try {    
                byte[] msg;
                if (textRadioButton.Checked) {
                    if (message == null)
                        return;
                    msg = Encoding.UTF8.GetBytes(message);
                }
                else {
                    if (string.IsNullOrEmpty(msgOpenDialog.FileName))
                        return;
                    msg = File.ReadAllBytes(msgOpenDialog.FileName);
                }

                if (!string.IsNullOrEmpty(passwordBox.Text))
                    msg = AESThenHMAC.SimpleEncryptWithPassword(msg, passwordBox.Text);

                int msgSize = t.GetRequiredSize(msg);

                requiredSizeBox.Text = SizeToString(msgSize);
                if (msgSize > maxSize) {
                    requiredSizeLabel.ForeColor = Color.Red;
                }
                else {
                    requiredSizeLabel.ForeColor = Color.Black;
                }
            }
            catch (FileNotFoundException ex) {
                ShowError(ex);
            }
            finally {
                t.Dispose();
            }
        }
예제 #2
0
        private Trithemius MakeTrithemius()
        {
            Trithemius t = new Trithemius(OpenBitmap(pathTextbox.Text));
            t.Color = (PixelColor)(pixelValueComboBox.SelectedIndex + 1);
            t.InvertBits = invertBox.Checked;

            if (!string.IsNullOrEmpty(seedBox.Text)) {
                t.Seed = new TrithemiusSeed(seedBox.Text);
            }

            t.LeastSignificantBits = (int)bitsNumericUpDown.Value;

            return t;
        }