title: C# RijndaelManaged to Python equivalent
body: <p>I have the following C# code (code is inherited and can't compile it). This is used to decrypt and unzip a saved file. </p>
  
  <pre><code>using System.Security.Cryptography;
  using System.Text;
  using ICSharpCode.SharpZipLib.Zip;
  
  //Not the real key but same amount of chars
  private const string kEncyptionKey = "01234567";
  
  public string DecryptAndDecompressText (string strFileName)
  {
      // Decryption ///
      FileStream fin = null;
      try
      {
          fin = new FileStream(strFileName, FileMode.Open, FileAccess.Read);
      }
      catch (System.IO.FileNotFoundException)
      {
          return "";
      }
  
      MemoryStream    memoryToDecompress =  new MemoryStream();
  
      UnicodeEncoding UE       = new UnicodeEncoding();
      RijndaelManaged RMCrypto = new RijndaelManaged();
  
      // This is the encryption key for our file 
      byte[] key = UE.GetBytes(kEncyptionKey);
  
      // Decrypt the data to a stream
      CryptoStream cs = new CryptoStream( memoryToDecompress, 
                                          RMCrypto.CreateDecryptor(key, key),
                                          CryptoStreamMode.Write);
      byte [] fileBuffer = new byte[fin.Length];
      fin.Read(fileBuffer, 0, fileBuffer.Length);
      cs.Write(fileBuffer, 0, fileBuffer.Length);
  
      fin.Close();
  
      // Reset the index of the Memory Stream
      memoryToDecompress.Position = 0;
  
      // Let the GC clean this up, we still need the memory stream
      //cs.Close();   
  
  
      // Decompress the File
      ZipInputStream s;
      s = new ZipInputStream(memoryToDecompress);
  
      ZipEntry theEntry;
      try
      {
          theEntry = s.GetNextEntry();
      }
      catch (System.Exception)
      {
          // Could not open the file...
          return "";
      }
  }
  </code></pre>
  
  <p>I'm trying to create a python program to do the same. This is what I've got:</p>
  
  <pre><code>from Crypto.Cipher import AES
  
  KEY = '01234567'.encode('utf-16be')
  
  _f = open('&lt;file&gt;', 'r')
  
   _content = _f.read()
  
  _cipher = AES.new(KEY, AES.MODE_CBC, KEY)
  
  _dcontent = _cipher.decrypt(_content)
  
  with open('extract.zip', 'w') as newfile:
      newfile.write(_dcontent)
  
  _f.close()
  </code></pre>
  
  <p>I'm writing the result to the disk since I expect it to be a zip file (which contains one file). However I can't open the file with Archive Manager. </p>
  
  <p>Any suggestions are welcome!</p>