SevenZipLoadOptions.DecryptionPassword

SevenZipLoadOptions.DecryptionPassword property

Gets or sets the password to decrypt entries and entry names.

public string DecryptionPassword { get; set; }

Examples

You can provide decryption password once on archive extraction.

using (FileStream fs = File.OpenRead("encrypted_archive.7z"))
{
    using (var extracted = File.Create("extracted.bin"))
    {
        using (SevenZipArchive archive = new SevenZipArchive(fs, new SevenZipLoadOptions() { DecryptionPassword = "p@s$" }))
        {
            using (var decompressed = archive.Entries[0].Open())
            {
                byte[] b = new byte[8192];
                int bytesRead;
                while (0 < (bytesRead = decompressed.Read(b, 0, b.Length)))
                    extracted.Write(b, 0, bytesRead);
                
            }
        }
    }
}

See Also