示例#1
0
        public void Execute()
        {
            if (_help)
            {
                _optionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            using (var fileStream = File.Open(_imagePath, FileMode.Open))
            {
                stenographer = new Stenographer(fileStream, Console.Out);
                if (!stenographer.Readable())
                {
                    Console.WriteLine("Error: image format not readable");
                    return;
                }
            }

            ICommand command = null;

            switch (_mode)
            {
            case Mode.Read:
                command = new Read(_imagePath, _outputPath, _secretKey, _ultraSecret);
                break;

            case Mode.Write:
                command = new Write(_imagePath, _outputPath, _secretDataPath, _secretKey, _ultraSecret);
                break;

            case Mode.Info:
                break;
            }
            command.Execute();
        }
示例#2
0
        public void Execute()
        {
            string outputString = null;

            using (var image = new Bitmap(Image.FromFile(_imagePath)))
            {
                outputString = Stenographer.ReadData(image, _secretKey);
            }

            if (!_ultraSecretMode)
            {
                if (string.IsNullOrEmpty(_outputPath))
                {
                    throw new ApplicationException("Error: missing outputpath parameter");
                }

                File.WriteAllText(_outputPath, outputString);
                Console.WriteLine("Corpse unburied! Be careful!");
            }
            else
            {
                Console.WriteLine("---BEGIN---");
                Console.WriteLine(outputString);
                Console.WriteLine("----END----");
                Console.WriteLine();
                Console.ReadKey();
                Console.Clear();
            }
        }
示例#3
0
        public void Execute()
        {
            if (string.IsNullOrEmpty(_outputPath))
            {
                throw new ApplicationException("Error: missing outputpath parameter");
            }

            string secretDataString = null;

            if (!_ultraSecret)
            {
                if (string.IsNullOrEmpty(_secretDataPath))
                {
                    throw new ApplicationException("Error: missing secretDataPath parameter");
                }

                var secretDataBytes = File.ReadAllBytes(_secretDataPath);
                secretDataString = Encoding.UTF8.GetString(secretDataBytes);
            }
            else
            {
                Console.WriteLine("Enter the text content to be hidden:");
                secretDataString = Console.ReadLine();
            }

            Bitmap outputBitmap = null;

            using (var fileStream = File.Open(_imagePath, FileMode.Open))
            {
                Stenographer stenographer = new Stenographer(fileStream, Console.Out);
                outputBitmap = stenographer.HideData(secretDataString, _secretKey);
            }

            outputBitmap.Save(_outputPath, ImageFormat.Png);

            Console.WriteLine($"Corpse buried at {_outputPath}! Take care!");
        }