0 votes
by (140 points)
reshown by

Hi,

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!

Peter

1 Answer

0 votes
by (134k points)

Hi,

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("password-encoding-sample.zip");
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:

"utf-8"
"windows-1252"
"iso-8859-1"
"windows-1250"
"iso-8859-2"
"iso-8859-15"
...