title: Decrypting using rijndael and C# issue
body: <p>I am encrypting some text and converting it to base64 and upon decryption I appear to have some odd characters as it blocks the rest of the output...</p>
  
  <p>For example, I want to encrypt 10,2013-12-16 10:22:24,1387189344 which converts to MaEA8gd7Xyg8tNBrtVBlb75U/a0J9x5x7UryI81gy3R+ZvL01p05uzDtzdBWL5Pg (base64) and then when I decrypt I try to print the output as "[" + decrypted + "]" but the second bracket doesn't come out.....</p>
  
  <p>Here's my code. Thanks in advance.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Text;
  using System.Windows.Forms;
  using DataSync;
  using System.IO;
  using System.Security.Cryptography;
  
  namespace EncryptionTest
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          // encrypt
          private void button1_Click(object sender, EventArgs e)
          {
              txtOutput.Text = Encrypt(txtData.Text, txtCIV.Text, txtSecret.Text);
  
          }
  
          // decrypt
          private void button2_Click(object sender, EventArgs e)
          {
              txtOutput.Text = "[" + Decrypt(txtData.Text, txtCIV.Text, txtSecret.Text) + "\r\n" + "]";
          }
  
  
  
          public string GenerateIV()
          {
              RijndaelManaged RM = new RijndaelManaged();
              RM.KeySize = 128;
              RM.BlockSize = 128;
              RM.Mode = CipherMode.CBC;
              RM.Padding = PaddingMode.Zeros;
  
              RM.GenerateIV();
  
              return Convert.ToBase64String(RM.IV);
          }
  
          public string Decrypt(string Encrypted, string IV, string SecretKey)
          {
              byte[] DecryptThis = Convert.FromBase64String(Encrypted);
              byte[] DecryptIV = Convert.FromBase64String(IV);
              byte[] Key = Encoding.UTF8.GetBytes(SecretKey);
  
              SHA256 SHA256Obj = SHA256.Create();
              byte[] PrivateKeyHash = SHA256Obj.ComputeHash(Key, 0, Key.Length);
  
              RijndaelManaged RM = new RijndaelManaged();
              RM.Mode = CipherMode.CBC;
              RM.Padding = PaddingMode.Zeros;
  
              MemoryStream ms = new MemoryStream();
              CryptoStream cs = new CryptoStream(ms, RM.CreateDecryptor(PrivateKeyHash, DecryptIV), CryptoStreamMode.Write);
  
              cs.Write(DecryptThis, 0, DecryptThis.Length);
              cs.FlushFinalBlock();
              cs.Close();          
  
              // Strip null (padding) characters
              int Position = -1;
              foreach (byte Char in ms.ToArray())
              {
                  ++Position;
                  if (Char == 0)
                  {
                  break;
                  }
              }
  
              string Temp = Encoding.UTF8.GetString(ms.ToArray());
  
              return Temp.Substring(0, Position+1).Trim();              
          }
  
          public string Encrypt(string ToBeEncrypted, string IV, string SecretKey)
          {
              byte[] EncryptThis = Encoding.UTF8.GetBytes(ToBeEncrypted);
              byte[] EncryptIV = Convert.FromBase64String(IV);
              byte[] Key = Encoding.UTF8.GetBytes(SecretKey);
  
              SHA256 SHA256Obj = SHA256.Create();
              byte[] PrivateKeyHash = SHA256Obj.ComputeHash(Key, 0, Key.Length);
  
              RijndaelManaged RM = new RijndaelManaged();
              RM.Mode = CipherMode.CBC;
              RM.Padding = PaddingMode.Zeros;
  
              MemoryStream ms = new MemoryStream();
              CryptoStream cs = new CryptoStream(ms, RM.CreateEncryptor(PrivateKeyHash, EncryptIV), CryptoStreamMode.Write);
  
              cs.Write(EncryptThis, 0, EncryptThis.Length);
              cs.FlushFinalBlock();
              cs.Close();
  
              return Convert.ToBase64String(ms.ToArray());
          }
      }
  }
  </code></pre>