Esempio n. 1
0
        private static void Input()
        {
            // Declare the password that will allow you to retrieve the encrypted data later
            var _PASSWORD = "******";

            // The String data to conceal on the image
            var _DATA_TO_HIDE = "Hello, no one should know that my password is 12345";

            // Declare the path where the original image is located
            var pathOriginalImage =
                @"/Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/screen.png";
            // Declare the new name of the file that will be generated with the hidden information
            var pathResultImage =
                @"/Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/image_example_with_hidden_information.png";

            // Create an instance of the SteganographyHelper
            var helper = new SteganographyHelper();

            // Encrypt your data to increase security
            // Remember: only the encrypted data should be stored on the image
            var encryptedData = StringCipher.Encrypt(_DATA_TO_HIDE, _PASSWORD);

            // Create an instance of the original image without indexed pixels
            var originalImage = SteganographyHelper.CreateNonIndexedImage(Image.FromFile(pathOriginalImage));
            // Conceal the encrypted data on the image !
            var imageWithHiddenData = SteganographyHelper.MergeText(encryptedData, originalImage);

            // Save the image with the hidden information somewhere :)
            // In this case the generated file will be image_example_with_hidden_information.png
            imageWithHiddenData.Save(pathResultImage);
        }
Esempio n. 2
0
        /// <summary>
        /// Encrypt the document.
        /// </summary>
        /// <param name="Doc"></param>
        /// <param name="Cancel"></param>
        private void HandleDocumentBeforeClose(Document Doc, ref bool Cancel)
        {
            string sidDocumentIdValue;

            if (!Doc.TryGetVariable(Constants.VariableName, out sidDocumentIdValue))
            {
                return;
            }

            string isEncryptedStr;
            bool   isEncrypted = false;

            if (Doc.TryGetVariable(Constants.IsEncryptedVariableName, out isEncryptedStr))
            {
                bool.TryParse(isEncryptedStr, out isEncrypted);
            }

            if (isEncrypted)
            {
                return;
            }

            // Encrypt the content.
            var encryptionHelper = new EncryptionHelper();
            var encryptedResult  = encryptionHelper.Encrypt(Doc, sidDocumentIdValue).Result;

            if (!string.IsNullOrWhiteSpace(AuthenticationStore.Instance().IdentityToken))
            {
                var officeDocumentStore = OfficeDocumentStore.Instance();
                officeDocumentStore.StoreDecryption(sidDocumentIdValue, new DecryptedResponse
                {
                    Password = encryptedResult.Password,
                    Salt     = encryptedResult.Salt
                });
            }

            // Insert the image.
            var range    = Doc.Range();
            var image    = ResourceHelper.GetImage("WordAccessManagementAddin.Resources.lock.png");
            var filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png";
            var bm       = SteganographyHelper.CreateNonIndexedImage(image);

            bm.Save(filePath);
            range.Text = string.Empty;
            var shape = range.InlineShapes.AddPicture(filePath, false, true);

            shape.AlternativeText = encryptedResult.Content;
            File.Delete(filePath);
            SetEncrypted(Doc, "true");
            Doc.Save();
        }
        private void HandleProtectOffline(object sender, RibbonControlEventArgs e)
        {
            var document = Globals.ThisAddIn.Application.ActiveDocument;
            var range    = document.Range();
            var xml      = range.XML;
            var image    = ResourceHelper.GetImage("WordAccessManagementAddin.Resources.lock.png");
            var filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png";
            var bm       = SteganographyHelper.CreateNonIndexedImage(image);

            bm.Save(filePath);
            range.Text = string.Empty;
            var shape = range.InlineShapes.AddPicture(filePath, false, true);

            shape.AlternativeText = xml;
            File.Delete(filePath);
        }
Esempio n. 4
0
        public static string Hide2(DataModel data, Image file, string filePath, string _PASSWORD,
                                   string filePathResult)
        {
            file.Save(filePath, ImageFormat.Png);
            // Encrypt your data to increase security
            // Remember: only the encrypted data should be stored on the image
            var encryptedData = StringCipher.Encrypt(data.Info, _PASSWORD);

            // Create an instance of the original image without indexed pixels
            var originalImage = SteganographyHelper.CreateNonIndexedImage(file);
            // Conceal the encrypted data on the image !
            var imageWithHiddenData = SteganographyHelper.MergeText(encryptedData, originalImage);

            // Save the image with the hidden information somewhere :)
            // In this case the generated file will be image_example_with_hidden_information.png
            imageWithHiddenData.Save(filePathResult);

            return("");
        }