Ejemplo n.º 1
0
 public Config(string defaultPath, string password, CryptographicAlgorithmImpl crypto,
     SteganographicAlgorithmImpl stego)
 {
     DefaultPath = defaultPath;
     Password = password;
     Crypto = crypto;
     Stego = stego;
 }
Ejemplo n.º 2
0
        public DecodeModel(string imageSrc, CryptographicAlgorithmImpl crypto, string passsword,
            SteganographicAlgorithmImpl stegano, bool compression, int lsbIndicator)
        {
            mSrcObj = imageSrc;
            mCompression = compression;

            //Crypt
            CryptoAlgorithm = crypto;
            mPassword = passsword;

            //Stegano
            SteganoAlgorithm = stegano;
            mLsbIndicator = lsbIndicator;
        }
Ejemplo n.º 3
0
        internal void Save(string password, CryptographicAlgorithmImpl selectedEncryptionMethod,
            SteganographicAlgorithmImpl selectedSteganographicMethod,
            string standardPath)
        {
            Password = password;
            SelectedEncryptionMethod = selectedEncryptionMethod;
            SelectedSteganographicMethod = selectedSteganographicMethod;
            DefaultPath = standardPath;

            var config = new Config(DefaultPath, Password, SelectedEncryptionMethod, SelectedSteganographicMethod);
            var file = Path.Combine(Constants.AppData, "Config.json");
            var sw = new StreamWriter(File.Create(file));
            using (var writer = new JsonTextWriter(sw))
            {
                mSerializer.Serialize(writer, config);
            }
        }
Ejemplo n.º 4
0
 public SteganographicModel(SteganographicAlgorithmImpl algorithm)
 {
     Algorithm = algorithm ?? AlgorithmList.FirstOrDefault();
 }
Ejemplo n.º 5
0
        /**
             * Combines two directories into an output directory.
             * <P>
             * The output directory (tempdir) will have all the original
             * images plus all the stegoimages copied into it.
             *
             * @param messagedir The directory full of messages in (txt files).
             * @param imagedir The directory full of images (png, jpg, bmp).
             * @param tempdir The directory to write the results to.
             * @param algorithm The algorithm to use to combine the messages and
             * images with.
             * @throws IllegalArgumentException If any directories are null.
             * @return A string full of skipped files.
             */
        public string CreateCombineDirectories(string messagedir, string imagedir, string tempdir,
            SteganographicAlgorithmImpl algorithm)
        {
            if (!Directory.Exists(messagedir) || !Directory.Exists(imagedir) || !Directory.Exists(tempdir))
            {
                throw new ArgumentException("Must be directories!");
            }

            var errors = new StringBuilder("Errors: \n========\n\n");
            var messageList = Directory.GetFiles(messagedir);
            var imagelist = Directory.GetFiles(imagedir);
            string coverfilepath, messagefilepath, outputpath, originalname;
            var fileseperator = Path.DirectorySeparatorChar;
            //	//for each file in the image folder...
            foreach (var imagefile in imagelist)
            {
                if (imagefile.EndsWith(".bmp") || imagefile.EndsWith(".jpg") || imagefile.EndsWith(".png"))
                {
                    //ok to combine it...
                    coverfilepath = imagedir;
                    originalname = imagefile.Substring(0, imagefile.IndexOf("."));
                    //for each message in the message folder...
                    foreach (var messagefile in messageList)
                    {
                        try
                        {
                            if (messagefile.EndsWith(".txt"))
                            {
                                //ok to combine...
                                messagefilepath = messagefile;

                                //setup the two files...

                                //setup the filename...
                                outputpath = originalname + "~" + messagefile.Substring(0, messagefile.LastIndexOf(".")) +
                                             "-"
                                             +
                                             algorithm.GetType()
                                                 .Name.ToLower()
                                                 .Substring(algorithm.GetType().Name.LastIndexOf(".") + 1,
                                                     algorithm.GetType().Name.Length) + "." + "png";

                                //write it
                                new Bitmap(algorithm.Encode(coverfilepath,
                                    new TextMessage(File.ReadAllText(messagefilepath)), 0)).Save(tempdir);
                            }
                        }
                        catch (Exception)
                        {
                            //just go onto the next one...
                            errors.Append("Error: Could not process: " + imagefile + " with " + messagefile + "\n");
                        }
                        //end image loop
                        //cleanup to speed up memory
                        GC.Collect();
                    }
                }
            }

            return errors.ToString();
        }