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 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); }