示例#1
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!");
        }