예제 #1
0
        private void Encrypt()
        {
            HandleJobController.Progress(() =>
            {
                //TODO compression
                var message   = GetCurrentMessage();
                var algorithm = ViewModel.CryptionModel.Algorithm as RsaAlgorithm;
                EncodeModel model;

                if (algorithm != null)
                {
                    string key;
                    using (var sr = new StreamReader(ViewModel.CryptionModel.KeyFilePath))
                    {
                        key = sr.ReadToEnd();
                    }

                    model = new EncodeModel(ViewModel.ImagePath, message, ViewModel.CryptionModel.Algorithm,
                                            key, ViewModel.SteganographicModel.Algorithm,
                                            ViewModel.SteganographicModel.Compression,
                                            ViewModel.SteganographicModel.LsbIndicator);
                }
                else
                {
                    model = new EncodeModel(ViewModel.ImagePath, message, ViewModel.CryptionModel.Algorithm,
                                            ViewModel.CryptionModel.Password, ViewModel.SteganographicModel.Algorithm,
                                            ViewModel.SteganographicModel.Compression,
                                            ViewModel.SteganographicModel.LsbIndicator);
                }

                var result       = model.Encode();
                ViewModel.Result = result;
            });
        }
예제 #2
0
        private string Encode(string src, string message, CryptographicAlgorithmImpl crypt = null,
                              string password = null, bool compression = false, int lsbIndicator = 3)
        {
            var model = new EncodeModel(src, message, crypt, password, Algorithm, compression, lsbIndicator);

            mStopwatch.Start();
            var result = model.Encode();

            mStopwatch.Stop();
            mEncryptionTime = mStopwatch.Elapsed;
            mStopwatch.Reset();
            return(result);
        }
예제 #3
0
        protected override void RunWithParameters()
        {
            if (Configured)
            {
                InitializeRun();
                //TODO Show process?
                var model = new EncodeModel(mImagePath, mMessage, GetCrypt(mCryptIndex), mPassword,
                                            GetStego(mStegoIndex), mCompression, mLsbIndicator);
                var result = model.Encode();
                Console.WriteLine();
                if (result != null)
                {
                    Console.WriteLine("ENCODING successfully. Please enter a path to save:");
                    var path = Console.ReadLine();
                    File.Move(result, mResultPath);
                    Console.WriteLine("Image saved at " + path);
                }

                Console.WriteLine("Press <ENTER> to exit.");
                Console.ReadLine();
            }
        }
예제 #4
0
        private Encoding checkBom(EncodeModel model, byte[] topBytes)
        {
            var bom = model.Bom;

            if (bom == null ||
                bom.Length == 0 ||
                bom.Length >= topBytes.Length)
            {
                return(model.Encoding);
            }
            else
            {
                //BOMチェック
                for (int i = 0; i < bom.Length; ++i)
                {
                    if (bom[i] != topBytes[i])
                    {
                        return(model.Encoding);
                    }
                }

                return(model.EncodingWithBom);
            }
        }
예제 #5
0
 public ModeIndex(EncodeModel model, int priority)
 {
     Model = model;
     Index = 0;
     Score = 0;
 }
예제 #6
0
 public ModeIndex(EncodeModel model) : this(model, 1000)
 {
 }