/// <summary>
        ///     Decrypts the archive to folder.
        /// </summary>
        /// <param name="selectedArchive">The selected archive.</param>
        /// <param name="privateKey">The private key.</param>
        /// <externalUnit/>
        /// <revision revisor="dev13" date="11/18/2009" version="1.1.3.6">
        ///     Added documentation header
        /// </revision>
        private void DecryptArchiveToFolder(
            string selectedArchive, string privateKey)
        {
            try
            {
                string folderPath = Path.GetDirectoryName(selectedArchive);

                string filename = Path.GetFileName(selectedArchive);

                string publicKey = string.Empty;

                FileManifestItem item = new FileManifestItem(
                    folderPath, filename);
                var validationResult = item.IsValid(folderPath);

                if (validationResult.Succeeded == false)
                {
                    MessageBox.Show("Validation of encrypted package failed.");
                }
                else
                {
                    MessageBox.Show(
                        "Validation of encrypted package succeeded.");
                }

                var result = EncryptedArchive.ExtractArchive(
                    folderPath, selectedArchive, new SequoiaCryptoProvider());

                if (result.Succeeded)
                {
                    MessageBox.Show(
                        "The selected archive has been extracted.",
                        "Archive extraction succeeded",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show(
                        result.Details,
                        "Archive extraction failed",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    string.Format(
                        "Error creating dencrypted archive folder: {0}",
                        exception.Message),
                    "Archive Decryption Failure",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }
Пример #2
0
        public void TestExtractZippedArchiveUsingStreamExtractor()
        {
            this.CleanTempPath(true);
            this.PopulateTempPath();

            this.MakeEncryptedArchiveHavingZip();

            //this.CleanTempPath(false);
            OperationResult result = EncryptedArchive.ExtractArchive(
                this.tempPath,
                Path.Combine(this.tempPath, "archive.enc"),
                new SequoiaCryptoProvider());

            Assert.AreEqual(string.Empty, result.Details);
            Assert.IsTrue(result.Succeeded);
        }