5

I did some investigation and cannot see native way to implement encryption/decryption using ZipArchive class.

https://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive(v=vs.110).aspx

It seems like MSDN does not provide this posibility...

Am I right and if I am not then how to encrypt/decrypt ZIP using ZipArchive class?

Thanks!

P.S. Is this approach a good one? Encrypt an existing zip file

Community
  • 1
  • 1
NoWar
  • 36,338
  • 80
  • 323
  • 498
  • Do yo need standard zip encryption or special one? – mkysoft Mar 15 '16 at 17:59
  • @mkysoft The beter choice for me is to use classes that Microsoft provides to manage ZIP. If it has standart ZIP encription than it will be enough. Thank you! – NoWar Mar 15 '16 at 20:21
  • 1
    .Net framework doesn't support encryption in ziparchive. If you can't use third party library, you can only implement encryption class to standard which are given by @Hans – mkysoft Mar 16 '16 at 13:27

1 Answers1

5

You can stop looking, Microsoft did not implement it. Encrypting the file(s) yourself before adding them to the archive is an obvious workaround but doesn't exactly give the recipient a shot at decrypting them again.

You'll have to fall back to the kind of libraries that were popular before .NET got zip file support. Lots to choose from, SharpZipLib and DotNetZip where the leading contenders. Both support a password on the archive and allow you to control the encryption algorithm when you create the archive, important if you care about the weak Zip 2.0 algorithm.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536