title: How to decrypt a Rijndael 128 encrypted text
body: <p>I'm trying to decrypt a Rijndael-128 encrypted cipher, these are the values:</p>
  <pre class="lang-none prettyprint-override"><code>Cipher: &quot;QfJzZ9V6Jm43jYPiVaXP9mu+f88S/JC24saHbOMxxC8=&quot;
  Key: &quot;45744855535472525844494538555934&quot;,
  Mode: CBC
  
  Result should be: &quot;abcd@1234&quot;
  </code></pre>
  <p>This website seems to decrypt the cipher just fine:
  <a href="https://codebeautify.org/encrypt-decrypt" rel="nofollow noreferrer">https://codebeautify.org/encrypt-decrypt</a></p>
  <p>I'm trying to do the same thing in C# with absolutely no luck, what am I missing here?</p>
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var text = Decrypt(&quot;QfJzZ9V6Jm43jYPiVaXP9mu+f88S/JC24saHbOMxxC8=&quot;, Convert.FromBase64String(&quot;45744855535472525844494538555934&quot;));
      }
  
      public static string Decrypt(string Text, byte[] keyBytes)
      {
          var textBytes = Convert.FromBase64String(Text);
  
          var rijKey = new RijndaelManaged();
  
          rijKey.IV = textBytes.Take(rijKey.BlockSize / 8).ToArray(); 
  
          rijKey.Padding = PaddingMode.None;
  
          rijKey.Mode = CipherMode.CBC;
  
          var  decryptor = rijKey.CreateDecryptor(keyBytes, rijKey.IV);
  
          var memoryStream = new MemoryStream(textBytes);
  
          var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
  
          var pTextBytes = new byte[textBytes.Length];
  
          var decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length);
  
          memoryStream.Close();
  
          cryptoStream.Close();
  
          string plainText = Encoding.UTF8.GetString(pTextBytes, 0, decryptedByteCount);
  
          return plainText;
      }
  }
  </code></pre>