title: PHP MCRYPT_RIJNDAEL_128 encryption in C#
body: <p>I'm trying to rewrite this function in C#. but the C# output mismatches the php </p>
  
  <p>PHP version</p>
  
  <pre><code>// Encrypt data using AES128-cbc
  function encrypt($data, $key, $iv) {
      $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
      mcrypt_generic_init($cipher, $key, $iv);
      $multipass = mcrypt_generic($cipher, $data);
      mcrypt_generic_deinit($cipher);
      return $multipass;
  }
  </code></pre>
  
  <p>C# Version</p>
  
  <pre><code>public static string encrypt(string encryptionString, string iv, string key)
  {
      byte[] clearTextBytes = Encoding.UTF8.GetBytes(encryptionString);
      var rijn = SymmetricAlgorithm.Create();
      rijn.KeySize = 128;
      rijn.Mode = CipherMode.CBC;
      var ms = new MemoryStream();
      var cs = new CryptoStream(ms, rijn.CreateEncryptor(Encoding.UTF8.GetBytes(key), Encoding.UTF8.GetBytes(iv)), CryptoStreamMode.Write);
      cs.Write(clearTextBytes, 0, clearTextBytes.Length);
      cs.Close();
      var tmp = Encoding.UTF8.GetString(ms.ToArray());
      return tmp;
  }
  </code></pre>