title: CTR mode use of Initial Vector(IV)
body: <p>from what I know, CTR mode doesn't use an Initial Vector.
  It just takes a counter, encrypts it with a given key and then XOR's the result with the plaintext in order to get the ciphertext.</p>
  
  <p>Other block cipher modes like CBC before doing the encryption they XOR the plaintext with an Initial Vector.</p>
  
  <p>So here is my problem. I have the following code in Java(using bouncycastle library):</p>
  
  <pre><code>Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding", "BC");
  
  cipher.init(Cipher.ENCRYPT_MODE, key);
  
  byte[] result = cipher.doFinal("Some plaintext");
  </code></pre>
  
  <p>Every different call of the above code with the same key gives different output! But when doing:</p>
  
  <pre><code>byte[] IV = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  
  Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding", "BC");
  
  cipher.init(Cipher.ENCRYPT_MODE, key, IV);
  
  byte[] result = cipher.doFinal("Some plaintext");
  </code></pre>
  
  <p>I take the same result in every call of the above code.
  But why is this? I mean, CTR doesn't need an IV, so why when I don't give an IV in every call I get a different result and when I given an IV it returns the same result? 
  If I always use the above IV(all zeroes) when using CTR, would that be safe?</p>
  
  <p>Any ideas would be very helpful.
  Thank you</p>