title: Rijndael 128/256 decryption
body: <p>I tried many answers from SO and all over the web but still without success. </p>
  
  <p>I use following <a href="http://www.bierkandt.org/encryption/symmetric_encryption.php" rel="nofollow">tool</a> to encrypt.</p>
  
  <pre><code>text to encrypt: tom
  key: exo123exo1exo123
  input (textfield or selected file above) is: text/binary
  Convert output to: [i leave this unselected]
  Mode: CTR
  Ciphers: Rijndael-128 and Rijndael-256
  </code></pre>
  
  <p>After getting result I move <a href="http://www.bierkandt.org/encryption/encoding.php" rel="nofollow">here</a>:</p>
  
  <p>and encode it with base64. </p>
  
  <p>Then I copy string and send it as a parameter to my function:</p>
  
  <pre><code>public String authenticate(String base64EncodedData){
  
      byte[] input = Base64.decodeBase64(base64EncodedData);
      byte[] ivBytes = "1234567812345678".getBytes();
  
  
      Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding");
  
      cipher.init(
          Cipher.DECRYPT_MODE,
          new SecretKeySpec("exo123exo1exo123".getBytes(), "AES"),
          new IvParameterSpec(ivBytes)
      );
  
      byte[] plainText = new byte[cipher.getOutputSize(input.length)];
      int plainTextLength = cipher.update(input, 0, input.length, plainText, 0);
      plainTextLength += cipher.doFinal(plainText, plainTextLength);
  
      return new String(plainText);  
    }
  </code></pre>
  
  <p>Result I got is always something similar to this (no matter if I use Rijndael-128 or 256 encrypted string):</p>
  
  <pre><code>.�v�Y�
  </code></pre>
  
  <p>When I try to return <code>input</code> value - I get the encrypted string. So base64 works just fine. 
  What I do wrong? 
  Am slowly getting mad here. 
  Thank you.</p>