Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Unable to unzip file with AES encryption

$
0
0

Hi,

I use the following code. The zip file creation is working but when I want to unzip the file I cannot do it if I use entry.AESKeySize = 256; if I comment it I can unzip the file without any problem. With the "Exctract" function of windows I get the following error "0x80004005 Unspecified error" and from 7zip "Cannot open output file"

Can you help me on this topic?

Thanks!

Guillaume

I use the following pasword to test "aB!1234567890@"

public void CreateDeliveryZipFile()
        {
            using (var zipOutputStream = new ZipOutputStream(File.Create(DeliveryZipFilePath)))
            {
                //zipOutputStream.SetLevel(0); // 0-9, 9 being the highest compression
                zipOutputStream.Password = _password;
                zipOutputStream.UseZip64 = UseZip64.Off;

                byte[ buffer = new byte[4096];
                foreach (var informationPackagePath in _informationPackagePaths)
                {
                    var entry = new ZipEntry(Path.GetFileName(informationPackagePath));
                    entry.DateTime = DateTime.Now;
                    entry.AESKeySize = 256;
                   

                    zipOutputStream.PutNextEntry(entry);
                    using (FileStream fs = File.OpenRead(informationPackagePath))
                    {
                        entry.Size = fs.Length;

                        int sourceBytes;
                        do
                        {
                            sourceBytes = fs.Read(buffer, 0, buffer.Length);
                            zipOutputStream.Write(buffer, 0, sourceBytes);
                        } while (sourceBytes > 0);
                    }

                    zipOutputStream.CloseEntry();


                    File.Delete(informationPackagePath);
                }
               
                zipOutputStream.Finish();
                zipOutputStream.Close();
            }
        }


Viewing all articles
Browse latest Browse all 1764

Trending Articles