Beispiel #1
0
        public void CompressTest()
        {
            string srcFilePath = PathHelper.GetFilePath(@"/Data/mountain.bmp");

            var expected = FileTransform.File2ByteArray(srcFilePath);

            var zipedSrcFileBytes = Zip.Compress(expected);

            var actual = Zip.Decompress(zipedSrcFileBytes);

            CollectionAssert.AreEqual(actual, expected);
        }
Beispiel #2
0
        public void HideTest1()
        {
            string file          = PathHelper.GetFilePath(@"\Data\testDocx.docx");
            string coverImageUri = PathHelper.GetFilePath(@"\Data\boy.bmp");
            Bitmap imgTohide     = new Bitmap(coverImageUri);

            var expected = FileTransform.File2ByteArray(file);

            HideLSB.Hide(ref imgTohide, expected);
            byte[] actual = HideLSB.DeHide(imgTohide);

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void WriteFileBodyTest1()
        {
            string dataPath = PathHelper.GetFilePath(@"\Data\testPng.png");

            byte[] bytesExpect = FileTransform.File2ByteArray(dataPath);

            string imagePath = PathHelper.GetFilePath(@"\Data\boy.bmp");
            Bitmap image     = new Bitmap(imagePath);

            HideLSB.WriteFileBody(ref image, bytesExpect, 0, 0);
            byte[] bytesActual = HideLSB.ReadFileBody(image, bytesExpect.Length * 8, 0, 0);

            CollectionAssert.AreEqual(bytesExpect, bytesActual);
        }
Beispiel #4
0
        public void File2ByteArrayTest()
        {
            string srcPath = PathHelper.GetFilePath(@"/Data/testDocx.docx");
            string outPath = PathHelper.GetFilePath("/Data/testDocx_out.docx");

            var expected = FileTransform.File2ByteArray(srcPath);

            FileTransform.ByteArray2File(outPath, expected);

            var actual = FileTransform.File2ByteArray(outPath);

            File.Delete(outPath);

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void ExecuteHideFile(object args)
        {
            try
            {
                var hideOption = this.GetHideOptionFromView((Window)args);

                if (hideOption == null)
                {
                    return;
                }

                var fileBytesToHide      = FileTransform.File2ByteArray(hideOption.FilePath);
                var zipedCoverImageBytes = Zip.Compress(fileBytesToHide);

                IEncryption encryptor = EncryptionFactory.CreateEncryption(hideOption.EncryptionAlg);

                var ciphertext = encryptor.Encrypt(zipedCoverImageBytes, this.StrPassword2UintArr(hideOption.Password));

                var tmpBitmapCacheToHide =
                    this._coverImageBitmapCache.Clone(
                        new Rectangle(0, 0, this._coverImageBitmapCache.Width, this._coverImageBitmapCache.Height),
                        this._coverImageBitmapCache.PixelFormat);

                HideLSB.Hide(ref tmpBitmapCacheToHide, ciphertext);

                this._hiddenImageBitmapCache = tmpBitmapCacheToHide;
                this.HiddenImage             = FileTransform.Bitmap2BitmapImage(this._hiddenImageBitmapCache);
            }
            catch (ImageHideCapacityTooSmallException)
            {
                this.ShowMessageBoxResource("HidingCapacityNotEnough", "Hint", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (IOException)
            {
                this.ShowMessageBoxResource("FileOpenError", "Error");
            }
            catch (Exception)
            {
                this.ShowMessageBoxResource("UnknownError", "Error");
            }
        }