title: What is the C# equivalent of Java BouncyCastle AES decryption?
body: <p>I have the following Java code that needs to be translated to c#:</p>
  
  <pre><code>public static byte[] encryptAES(byte[] toEncrypt, byte[] key,
                                  boolean encrypte) throws Exception {
  
      Security.addProvider(new BouncyCastleProvider());
  
      byte[] iv = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
  
      IvParameterSpec salt = new IvParameterSpec(iv);
      Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC");
  
      if (encrypte == false)
          cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"),  salt);
      else
          cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"),  salt);
  
      byte[] result = cipher.doFinal(toEncrypt);
      return result;
  }
  </code></pre>
  
  <p>How do you do the equivalent of:</p>
  
  <pre><code>Security.addProvider(new BouncyCastleProvider());
  </code></pre>
  
  <p>and what is the equivalent of:</p>
  
  <pre><code>IvParameterSpec salt = new IvParameterSpec(iv);
  Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC");
  </code></pre>