C# を使用して ZIP アーカイブをロックする方法

Aspose.Zip for .NET は、開発者が ZIP アーカイブを簡単にロックし、ファイルに追加のセキュリティ層を追加できる強力なアプリケーションです。 Aspose.Zip ライブラリが提供する Lock メソッドを利用することで、開発者は zip アーカイブのパスワードを簡単に設定できます。この機能により、許可された個人のみがアーカイブのコンテンツにアクセスできるようになり、機密データが不正アクセスから保護されます。 ZIP、GZIP、BZIP2、TAR、CPIO、LZIP、7Z、LZMA、XZ、Z などのさまざまな圧縮形式をサポートする Aspose.Zip は、さまざまな種類のアーカイブを処理するための包括的なソリューションを提供します。直感的でユーザーフレンドリーな API により、開発者は、Web ベースであっても であっても、 パスワード保護を .NET アプリケーションにシームレスに統合できます。 Windows、Linux、または macOS で実行されるオンライン アプリケーション を圧縮します。 Aspose.Zip を利用することで、開発者は zip アーカイブのセキュリティを強化し、ファイルの機密性を確保できます。

ファイル圧縮およびアーカイブ .NET API を使用して NuGet パッケージを管理する

Aspose.ZIP for .NET は、.NET 開発者がさまざまなアーカイブ処理タスクを処理できるように設計された強力なクラス ライブラリです。 ZIP、GZIP、BZIP2、TAR、CPIO、LZIP、7Z、LZMA、XZ、Z などの複数の形式をサポートしており、広範な機能を提供します。開発者は、このライブラリを利用して、ファイルの暗号化と復号化、自己解凍アーカイブの作成、RAR、CAB、および WIM 形式の抽出を行うことができます。

API は使いやすく、シンプルさと信頼性を提供します。 。これはマネージド C# を使用して実装されており、C#、VB.NET、F# などの .NET 言語とシームレスに統合できます。 ASP.NET Web アプリケーションで作業している場合でも、フォーム アプリケーションで作業している場合でも、Windows、Linux、MacOS などのオペレーティング システムに関係なく、簡単に統合できます。 Aspose.ZIP for .NET を利用することで、開発者は .NET アプリケーション内でアーカイブ処理タスクを処理するための多用途のソリューションを得ることができます。


C# で ZIP アーカイブを保護する手順

Protecting archive using password with

Aspose.ZIP for .NET

APIs can be done with just few lines of code.

  • Create FileStream object with the output ZIP archive file path as parameter with mod FileMode.Create.
  • Open and read the source file into a FileStream object with mod FileMode.Open and FileAccess.Read.
  • Create Archive class object with ArchiveEntrySettings object as parameter.
  • Use TraditionalEncryptionSettings as parameters to ArchiveEntrySettings.
  • Use Archive.Save(FileStream) method for creating the archive.

システム要求

Before running the conversion example code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework, Mono and COM Interop.
  • Development environment like Microsoft Visual Studio.
  • Aspose.Tasks for .NET DLL referenced in your project.

ZIP アーカイブをロックする - C# コード例

using (FileStream zipFile = File.Open(dataDir + "CompressWithTraditionalEncryption_out.zip", FileMode.Create))
{
    using (FileStream source1 = File.Open(dataDir + "alice29.txt", FileMode.Open, FileAccess.Read))
    {
        var archive = new Archive(new ArchiveEntrySettings(null, new TraditionalEncryptionSettings("p@s$")));
        archive.CreateEntry("alice29.txt", source1);
        archive.Save(zipFile);
    }
}



よくある質問セクション

People have been asking

1. How can I unlock a password-protected zip archive?

To unlock a password-protected zip archive, you need to provide the correct password. You can use the appropriate method or property of the zip library you are using to set the password, and then extract the files from the archive using that password.

2. Can I remove or change the password of a locked zip archive?

Yes, it is possible to remove or change the password of a locked zip archive. You can use the library’s methods or properties to modify the password. Typically, you would need to provide the current password to remove it or provide the current password along with the new password to change it.

3. Is it possible to recover a forgotten password for a locked zip archive?

Recovering a forgotten password for a locked zip archive is extremely difficult, if not impossible, without specialized tools. Zip archives are designed to provide strong encryption, and forgetting the password means losing access to the contents of the archive. It is recommended to keep your passwords safe and secure to avoid such situations.

保護された ZIP アーカイブ操作

Aspose.Zip は、ZIP アーカイブのセキュリティをさらに強化するためのさまざまな暗号化オプションを提供します。開発者は、AES128、AES192、AES256 などの AES 暗号化アルゴリズムを利用して、アーカイブ内のファイルを暗号化できます。これにより、特定のセキュリティ要件に合わせてさまざまなキー長を使用したより強力な暗号化が可能になります。さらに、Aspose.Zip は単一アーカイブ内の複数のファイルの暗号化をサポートしているため、開発者は特定のニーズに基づいて暗号化技術を混合して利用できます。これらの高度な暗号化機能により、Aspose.Zip は開発者が ZIP アーカイブ内の機密データを保護するための堅牢なセキュリティ対策を実装できるようにします。

サポートされているその他の Aspose.Zip for .NET API 機能

Aspose.Zip C# ライブラリを使用して、アーカイブの変換、圧縮、ロック、ロック解除、解凍などを行います。

Compression (Archive compressions)
Conversions (Rar to 7Zip)
Extract (Extracting Archives)
Lock (Archive lock)
Lock (Archive unlock)
ZIP Viewer (ZIP File Viewer)
Creating Archive (Add files or folders to ZIP)