0 votes
asked Nov 23, 2019 by -prh (140 points)
reshown Nov 25, 2019 by -prh


I am using the current version of REBEX Zip.

Unfortunately I have problems decompressing existing zip files (AES-256 encrypted) containing passwords with special characters (e.g. $, %, öäü).

In an older article I read a hint to "ZipArchiveOptions.PasswordEncoding".

Unfortunately I don't know how to use this option correctly (syntax, values etc.).

Maybe someone can help me. An example would be nice!


1 Answer

0 votes
answered Nov 25, 2019 by Lukas Pokorny (121,330 points)


PasswordEncoding option is supposed to be set to an instance of .NET's Encoding class that specifies the encoding (character set) to use to transform the password from a string to a byte array.

So in order to specify a particular encoding, do this:

using Rebex.IO.Compression;
using System.Text;

// encoding to use
string encoding = "windows-1252";

var zip = new ZipArchive("");
zip.Options.PasswordEncoding = Encoding.GetEncoding(encoding);
zip.Password = "öäü";
zip.ExtractAll("output", ActionOnExistingFiles.OverwriteAll);

The sample ZIP file is available here.

To determine a list of all possible character encodings, use Encoding.GetEncodings() method.

Western European languages usually use one of the following encodings: