public void ExecuteRetrieveFile(object args) { try { var deHideOption = this.GetDeHideOptionFromView((Window)args); if (deHideOption == null) { return; } var ciphertext = HideLSB.DeHide(this._hiddenImageBitmapCache); IEncryption encryptor = EncryptionFactory.CreateEncryption(deHideOption.EncryptionAlg); var plaintext = encryptor.Decrypt(ciphertext, this.StrPassword2UintArr(deHideOption.Password)); var deZipdata = Zip.Decompress(plaintext); if (File.Exists(deHideOption.FilePath)) { File.Delete(deHideOption.FilePath); } FileTransform.ByteArray2File(deHideOption.FilePath, deZipdata); this.ShowMessageBoxResource("RetrieveDone", "Hint", MessageBoxButton.OK, MessageBoxImage.Information); } catch (PasswordWrongException) { this.ShowMessageBoxResource("PasswordWrong", "Error"); } catch (Exception) { this.ShowMessageBoxResource("PasswordWrong", "Error"); } }
public void ExtractColorRedsTest() { Bitmap img = CreateABitmap(300, 200, 2, 1, 1); List <byte> colorReds = HideLSB.ExtractColorReds(img, 600, 1, 1); for (int i = 0; i < 600; i++) { Assert.AreEqual(2, colorReds[i]); } }
public void HideTest2() { Bitmap imgToHide = CreateABitmap(200, 300, 0, 0, 0); byte[] expeceted = { 211, 66, 127, 87, 56 }; HideLSB.Hide(ref imgToHide, expeceted); byte[] actual = HideLSB.DeHide(imgToHide); CollectionAssert.AreEqual(expeceted, actual); }
public void GetBitsFromColorRedsLsbTest() { List <byte> colorReds = new List <byte> { 1, 2, 3, 4, 5, 6, 7, 8 }; byte[] expected = { 1, 0, 1, 0, 1, 0, 1, 0 }; List <byte> actual = HideLSB.ExtractBitsFromColorRedsLsb(colorReds); CollectionAssert.AreEqual(expected, actual); }
public void HideTest() { string imageUri = PathHelper.GetFilePath(@"\Data\boy.bmp"); Bitmap imgToHide = new Bitmap(imageUri); byte[] bytesData = { 211, 66, 127, 87, 56 }; HideLSB.Hide(ref imgToHide, bytesData); byte[] data = HideLSB.DeHide(imgToHide); CollectionAssert.AreEqual(bytesData, data); }
public void WriteFileBodyTest2() { string imagePath = PathHelper.GetFilePath(@"\Data\boy.bmp"); Bitmap image = new Bitmap(imagePath); byte[] bytesExpect = { 1, 2, 3, 4, 5, 6 }; HideLSB.WriteFileBody(ref image, bytesExpect, 5, 7); byte[] bytesActual = HideLSB.ReadFileBody(image, 48, 5, 7); CollectionAssert.AreEqual(bytesExpect, bytesActual); }
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); }
public void ExecuteEraseFile() { HideLSB.Erase(ref this._hiddenImageBitmapCache); this.HiddenImage = FileTransform.Bitmap2BitmapImage(this._hiddenImageBitmapCache); if (File.Exists(this.ImageFilePath)) { File.Delete(this.ImageFilePath); } this._hiddenImageBitmapCache.Save(this.ImageFilePath); this.ShowMessageBoxResource("RetrieveDone", "Hint", MessageBoxButton.OK, MessageBoxImage.Information); }
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); }
public void SetImageColorRedsTest2() { Bitmap imgToHide = CreateABitmap(2, 3, 0, 0, 0); List <byte> expected = new List <byte> { 1, 2, 3, 4, 5, 6 }; HideLSB.SetImageColorReds(ref imgToHide, 0, 0, expected); List <byte> actual = HideLSB.ExtractColorReds(imgToHide, expected.Count, 0, 0); CollectionAssert.AreEqual(expected, actual); }
public void WriteFileHeadTest1() { Bitmap imgToHide = CreateABitmap(200, 300, 0, 0, 0); int expected = 260000; int?x = 0; int?y = 0; HideLSB.WriteFileHead(ref imgToHide, expected, out x, out y); x = 0; y = 0; int actual = HideLSB.ReadFileHead(imgToHide, out x, out y); Assert.AreEqual(expected, actual); }
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"); } }