Пример #1
0
        private async void HideInformation()
        {
            if (textForHide.Length > 0)
            {
                sourceString    = textForHide;
                TimeForCrypting = string.Empty;

                //if(RandomCheckBox.IsChecked)
                //    CurrentShift = 0;

                string pathToNewFile = DocumentHelper.CopyFile(pathToDirOrigFile, filenameOrigFile);
                bool   isSuccesful   = false;

                Stopwatch.Restart();
                sourceString = SelectedCryptMethod?.Encrypt(sourceString, pathToDirOrigFile) ?? sourceString;

                var hash = SelectedHashMethod?.GetHash(SelectedCryptMethod == null ? sourceString : Converter.BinaryToString(sourceString));
                if (!string.IsNullOrWhiteSpace(hash))
                {
                    MD5.SaveHash(pathToDirOrigFile, hash); //Mocked until base class will not be implemented
                }

                sourceString = SelectedCodMethod?.Coding(SelectedCryptMethod != null ? sourceString : Converter.StringToBinary(sourceString)) ?? sourceString;

                if (SelectedCryptMethod == null && SelectedCodMethod == null)
                {
                    sourceString = Converter.StringToBinary(sourceString);
                }

                HideFontModel codeModel = new HideFontModel(pathToNewFile);
                isSuccesful = await codeModel.HideInformation(sourceString.ToCharArray(), CurrentShift, RandomCheckBox.IsChecked, VisibleColorCheckBox.IsChecked, OneFontName, ZeroFontName);

                Stopwatch.Stop();
                TimeForCrypting = Math.Round(Stopwatch.Elapsed.TotalSeconds, 2).ToString() + " сек.";

                if (isSuccesful)
                {
                    ShowMetroMessageBox("Информация", "Скрытие информации прошло успешно.\n\nПуть к измененному файлу: " + pathToNewFile);
                    KeyStatus      = (SelectedCryptMethod != null) ? "сгенерирован" : "выключен";
                    KeyStatusColor = (SelectedCryptMethod != null) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Black);
                }
                else
                {
                    ShowMetroMessageBox("Информация", "Во время выполнения произошла ошибка.");
                    KeyStatus      = (SelectedCryptMethod != null) ? "ошибка генерации" : "выключен RSA";
                    KeyStatusColor = (SelectedCryptMethod != null) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black);
                }
            }
            else
            {
                ShowMetroMessageBox("Ошибка", "Введите текст.");
            }
            //TextForHide = String.Empty;
        }
        private void HideInformation()
        {
            if (textForHide.Length > 0)
            {
                sourceString = textForHide;

                if (SmartHidingCheckBox.IsChecked)
                {
                    ShowMetroMessageBox("Предупреждение", "При выбранном умном скрытии автоматически будет включена псевдорандомизация, \n\tа визуальное выделение отключено!\n");
                    RandomCheckBox.IsChecked       = true;
                    VisibleColorCheckBox.IsChecked = false;
                }
                string pathToNewFile = DocumentHelper.CopyFile(pathToDirOrigFile, filenameOrigFile);
                bool   isSuccesful   = false;

                Stopwatch.Restart();
                sourceString = SelectedCryptMethod?.Encrypt(sourceString, pathToDirOrigFile) ?? sourceString;

                var hash = SelectedHashMethod?.GetHash(SelectedCryptMethod == null ? sourceString : Converter.BinaryToString(sourceString));
                if (!string.IsNullOrWhiteSpace(hash))
                {
                    MD5.SaveHash(pathToDirOrigFile, hash); //Mocked until base class will not be implemented
                }

                sourceString = SelectedCodMethod?.Coding(SelectedCryptMethod != null ? sourceString : Converter.StringToBinary(sourceString)) ?? sourceString;

                HideAproshModel codeModel = new HideAproshModel(pathToNewFile);
                isSuccesful = codeModel.HideInformation(sourceString.ToCharArray(), VisibleColorCheckBox.IsChecked, RandomCheckBox.IsChecked, ZeroBitSpacing, SoloBitSpacing);


                Stopwatch.Stop();
                TimeForCrypting = Math.Round(Stopwatch.Elapsed.TotalSeconds, 2).ToString() + " сек.";

                if (isSuccesful)
                {
                    ShowMetroMessageBox("Информация", "Скрытие информации прошло успешно.\n\nПуть к измененному файлу: " + pathToNewFile);
                }
                else
                {
                    ShowMetroMessageBox("Информация", "Во время выполнения произошла ошибка.");
                }
            }
            else
            {
                ShowMetroMessageBox("Ошибка", "Введите текст.");
            }
        }
Пример #3
0
        //private void OpenDocument()
        //{
        //    if (OpenFileDialog(openFileDialog) != null)
        //    {
        //        FullPathToOrigFile = openFileDialog.FileName;
        //        filenameOrigFile = openFileDialog.SafeFileName;
        //        pathToDirOrigFile = fullPathToOrigFile.Substring(0, fullPathToOrigFile.Length - filenameOrigFile.Length);

        //        CountLettersIsCanHide = HideColorModel.HowMuchLettersICanHide(fullPathToOrigFile).ToString();
        //        maxLettersIsCanHide = Int32.Parse(countLettersIsCanHide);
        //        if (Int32.Parse(countLettersIsCanHide) > 0)
        //        {
        //            IsTextForHideEnabled = true;
        //            IsHideInformationButtonEnabled = true;

        //            RandomCheckBox.IsEnabled = true;
        //            RSACheckBox.IsEnabled = true;
        //            AdditionalBitsCheckBox.IsEnabled = true;
        //            VisibleColorCheckBox.IsEnabled = true;
        //            SmartHidingCheckBox.IsEnabled = true;
        //        }
        //        else
        //        {
        //            ShowMetroMessageBox("Ошибка", "В данном файле невозможно скрыть информацию.");
        //        }
        //    }
        //}

        private async void HideInformation()
        {
            if (textForHide.Length > 0)
            {
                sourceString = textForHide;

                if (SmartHidingCheckBox.IsChecked)
                {
                    ShowMetroMessageBox("Предупреждение", "При выбранном умном скрытии автоматически будет включена псевдорандомизация, \n\tа визуальное выделение отключено!\n");
                    RandomCheckBox.IsChecked       = true;
                    VisibleColorCheckBox.IsChecked = false;
                }
                string pathToNewFile = DocumentHelper.CopyFile(pathToDirOrigFile, filenameOrigFile);
                bool   isSuccesful   = false;

                //textForHide = (RSACheckBox.IsChecked)
                //    ? Converter.RsaCryptor(TextForHide, pathToDirOrigFile)
                //    : Converter.StringToBinary(TextForHide);

                //textForHide = (AdditionalBitsCheckBox.IsChecked)
                //    ? HideColorModel.AddAdditionalBits(textForHide)
                //    : textForHide;
                Stopwatch.Restart();
                sourceString = SelectedCryptMethod?.Encrypt(sourceString, pathToDirOrigFile) ?? sourceString;

                var hash = SelectedHashMethod?.GetHash(SelectedCryptMethod == null ? sourceString : Converter.BinaryToString(sourceString));
                if (!string.IsNullOrWhiteSpace(hash))
                {
                    MD5.SaveHash(pathToDirOrigFile, hash); //Mocked until base class will not be implemented
                }

                sourceString = SelectedCodMethod?.Coding(SelectedCryptMethod != null ? sourceString : Converter.StringToBinary(sourceString)) ?? sourceString;

                if (SelectedCryptMethod == null && SelectedCodMethod == null)
                {
                    sourceString = Converter.StringToBinary(sourceString);
                }

                HideColorModel codeModel = new HideColorModel(pathToNewFile);
                isSuccesful = await codeModel.HideInformation(sourceString.ToCharArray(), RandomCheckBox.IsChecked, VisibleColorCheckBox.IsChecked, SmartHidingCheckBox.IsChecked);

                Stopwatch.Stop();
                TimeForCrypting = Math.Round(Stopwatch.Elapsed.TotalSeconds, 2).ToString() + " сек.";

                if (isSuccesful)
                {
                    ShowMetroMessageBox("Информация", "Скрытие информации прошло успешно.\n\nПуть к измененному файлу: " + pathToNewFile);
                    //KeyStatus = (RSACheckBox.IsChecked == true) ? "сгенерирован" : "выключен RSA";
                    //KeyStatusColor = (RSACheckBox.IsChecked == true) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Black);
                }
                else
                {
                    ShowMetroMessageBox("Информация", "Во время выполнения произошла ошибка.");
                    //KeyStatus = (RSACheckBox.IsChecked == true) ? "ошибка генерации" : "выключен RSA";
                    //KeyStatusColor = (RSACheckBox.IsChecked == true) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black);
                }
            }
            else
            {
                ShowMetroMessageBox("Ошибка", "Введите текст.");
            }
            //TextForHide = String.Empty;
        }
        private async void HideInformation()
        {
            if (textForHide.Length > 0)
            {
                sourceString = textForHide;

                if (SmartHidingCheckBox.IsChecked)
                {
                    ShowMetroMessageBox("Предупреждение", "При выбранном умном скрытии автоматически будет включена псевдорандомизация, \n\tа визуальное выделение отключено!\n");
                    RandomCheckBox.IsChecked       = true;
                    VisibleColorCheckBox.IsChecked = false;
                }

                string pathToNewFile = DocumentHelper.CopyFile(pathToDirOrigFile, filenameOrigFile);
                bool   isSuccesful   = false;



                //textForHide = (RSACheckBox.IsChecked)
                //    ? Converter.RsaCryptor(TextForHide, pathToDirOrigFile)
                //    : Converter.StringToBinary(TextForHide);

                //MessageBox.Show("ee"+textForHide);

                //textForHide = (AdditionalBitsCheckBox.IsChecked)
                //    ? HideUnderlineModel.AddAdditionalBits(textForHide)
                //    : textForHide;

                //textForHide = Converter.StringToBinary(textForHide);



                //MessageBox.Show("ee1" + textForHide);

                //textForHide = (ShifrElGamalCheckBox.IsChecked)
                // ? HideUnderlineModel.HideUnderlineElGamal(textForHide)
                // : Converter.StringToBinary(TextForHide);

                //MessageBox.Show("text"+textForHide);


                textForHide = SelectedCryptMethod?.Encrypt(textForHide, pathToDirOrigFile)
                              ?? textForHide;

                //MessageBox.Show("криптаt" + textForHide);

                textForHide = SelectedCodMethod?.Coding(SelectedCryptMethod != null
                    ? textForHide : Converter.StringToBinary(TextForHide))
                              ?? TextForHide;
                MessageBox.Show(textForHide);

                //AttributeHidingModel codeModel = new AttributeHidingModel(pathToNewFile);
                //isSuccesful = await codeModel.HideInformation(textForHide.ToCharArray(), VisibleColorCheckBox.IsChecked, SelectedCodMethod != null, SelectedCryptMethod != null);

                HideUnderlineModel codeModel = new HideUnderlineModel(pathToNewFile);
                isSuccesful = await codeModel.HideInformation(textForHide.ToCharArray(), RandomCheckBox.IsChecked, VisibleColorCheckBox.IsChecked, OneFontName, ZeroFontName);


                var hash = SelectedHashMethod?.GetHash(SelectedCryptMethod == null || SelectedCodMethod != null ? TextForHide : Converter.BinaryToString(TextForHide)) ?? TextForHide;
                if (!string.IsNullOrWhiteSpace(hash))
                {
                    MD5.SaveHash(pathToDirOrigFile, hash); //Mocked until base class will not be implemented
                }

                if (isSuccesful)
                {
                    ShowMetroMessageBox("Информация", "Скрытие информации прошло успешно.\n\nПуть к измененному файлу: " + pathToNewFile);
                    KeyStatus      = (RSACheckBox.IsChecked == true) ? "сгенерирован" : "выключен RSA";
                    KeyStatusColor = (RSACheckBox.IsChecked == true) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Black);
                }
                else
                {
                    ShowMetroMessageBox("Информация", "Во время выполнения произошла ошибка.");
                    KeyStatus      = (RSACheckBox.IsChecked == true) ? "ошибка генерации" : "выключен RSA";
                    KeyStatusColor = (RSACheckBox.IsChecked == true) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black);
                }
            }
            else
            {
                ShowMetroMessageBox("Ошибка", "Введите текст.");
            }
            //TextForHide = String.Empty;
        }