title: How to create a encrypted zip file can be decompressed by winzip/7zip
body: <p>I've used AESManaged Class to encrypt a zip file, but it couldn't be decompressed by winzip/7zip. I can only decompress it after decrypting in my code.</p>
  
  <p>Below is the code I used to encrypt and decrypt. Anyone can help?</p>
  
  <pre><code>private static void EncryptFile(string input, string output, string pwd)
      {
          using (AesManaged aes = new AesManaged())
          {
              FileStream fsCrypt=null;
              try
              {
                  byte[] key = Encoding.UTF8.GetBytes(pwd);
  
                  fsCrypt = new FileStream(output, FileMode.Create);
  
                      using (CryptoStream cs = new CryptoStream(fsCrypt, aes.CreateEncryptor(key, key), CryptoStreamMode.Write))
                      {
                          using (FileStream fsIn = new FileStream(input, FileMode.Open))
                          {
                              int data;
  
                              while ((data = fsIn.ReadByte()) != -1)
                              {
                                  cs.WriteByte((byte)data);
                              }
                              aes.Clear();
                          }
                      }
  
              }
              catch (Exception ex)
              {
                  Console.WriteLine(ex.Message);
                  aes.Clear();
              }
              finally
              {
                  if(fsCrypt!=null)
                  {
                      fsCrypt.Dispose();
                  }
              }
          }
      }
  
  
      private static void DecryptFile(string input, string output, string pwd)
      {
          using (AesManaged aes = new AesManaged())
          {
              FileStream fsCrypt = null;
              try
              {
                  byte[] key = Encoding.UTF8.GetBytes(pwd);
  
                  fsCrypt = new FileStream(input, FileMode.Open);
                  {
  
                      using (FileStream fsOut = new FileStream(output, FileMode.Create))
                      {
                          using (CryptoStream cs = new CryptoStream(fsCrypt, aes.CreateDecryptor(key, key), CryptoStreamMode.Read))
                          {
                              int data;
  
                              while ((data = cs.ReadByte()) != -1)
                              {
                                  fsOut.WriteByte((byte)data);
                              }
                              aes.Clear();
                          }
                      }
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine(ex.Message);
                  aes.Clear();
              }
              finally
              {
                  if (fsCrypt != null)
                  {
                      fsCrypt.Dispose();
                  }
              }
          }
      }
  </code></pre>