title: Encrypted bytes is not recognized by Java from Javascript?
body: <p>I've done the <strong>AES CTR</strong> implementation on Javascript. Now I'm intended to share the encrypted bytes to Java for further processing. However I'm unable to assign the value return from <code>JavaScript's Uint8Array</code> to <code>Java's byte[]</code>.</p>
  <p>Below's a sample data in <code>Uint8Array</code> format (After AES CTR encryption)</p>
  <pre><code>[71, 193, 223, 190, 6, 104, 11, 235, 249, 96, 54, 192, 233, 41, 198, 188, 15, 218, 10, 0, 61, 95, 58, 122, 74, 169, 27, 228, 121, 224, 128, 124, 198, 183, 23, 36, 89, 105, 184, 59, 245, 115, 244, 22, 122, 207, 217, 219, 160, 2, 227, 175, 134, 66, 165, 73, 102, 52, 14, 150, 182, 187, 228, 173, 96, 68, 11, 35, 166, 247, 45, 18, 202, 99, 81, 185, 216, 240, 66, 10, 105, 122, 45, 83]
  </code></pre>
  <p>When I pass try hardcoding value received from <code>JavaScript</code> in <code>Java</code> under <code>byte[]</code> as show, I received following complain.</p>
  <pre><code>byte[] resp = {71, 193, 223, 190, 6, 104, 11, 235, 249, 96, 54, 192, 233, 41, 198, 188, 15, 218, 10, 0, 61, 95, 58, 122, 74, 169, 27, 228, 121, 224, 128, 124, 198, 183, 23, 36, 89, 105, 184, 59, 245, 115, 244, 22, 122, 207, 217, 219, 160, 2, 227, 175, 134, 66, 165, 73, 102, 52, 14, 150, 182, 187, 228, 173, 96, 68, 11, 35, 166, 247, 45, 18, 202, 99, 81, 185, 216, 240, 66, 10, 105, 122, 45, 83};
  
  // The complain is as follow:
  Required type: byte
  Provided: int
  </code></pre>
  <p>I did this for <strong>resolving to the above issue</strong>:</p>
  <pre><code>byte[] resp = {71, (byte)193, (byte)223, (byte)190, 6, 104, 11, (byte)235, (byte)249, 96, 54, (byte)192, (byte)233, 41, (byte)198, (byte)188, 15, (byte)218, 10, 0, 61, 95, 58, 122, 74, (byte)169, 27, (byte)228, 121, (byte)224, (byte)128, 124, (byte)198, (byte)183, 23, 36, 89, 105, (byte)184, 59, (byte)245, 115, (byte)244, 22, 122, (byte)207, (byte)217, (byte)219, (byte)160, 2, (byte)227, (byte)175, (byte)134, 66, (byte)165, 73, 102, 52, 14, (byte)150, (byte)182, (byte)187, (byte)228, (byte)173, 96, 68, 11, 35, (byte)166, (byte)247, 45, 18, (byte)202, 99, 81, (byte)185, (byte)216, (byte)240, 66, 10, 105, 122, 45, 83};
  </code></pre>
  <h3>Below is to show some implemented of the code</h3>
  <p><strong>JS</strong></p>
  <pre><code>    var key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      var textBytes = aesjs.utils.utf8.toBytes(&quot;textToEncrypt&quot;);
      var aesCtr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(16));
      var encryptedBytes = aesCtr.encrypt(textBytes);
  
  # Outcome of encryptedBytes
  [71, 193, 223, 190, 6, 104, 11, 235, 249, 96, 54, 192, 233, 41, 198, 188, 15, 218, 10, 0, 61, 95, 58, 122, 74, 169, 27, 228, 121, 224, 128, 124, 198, 183, 23, 36, 89, 105, 184, 59, 245, 115, 244, 22, 122, 207, 217, 219, 160, 2, 227, 175, 134, 66, 165, 73, 102, 52, 14, 150, 182, 187, 228, 173, 96, 68, 11, 35, 166, 247, 45, 18, 202, 99, 81, 185, 216, 240, 66, 10, 105, 122, 45, 83]
  </code></pre>
  <p><strong>Java</strong></p>
  <pre><code>byte[] keyBytes = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  byte[] ivBytes = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
  
  # Here I assign the value I've received from `Javascript` into `resp`
  
  byte[] resp = {71, (byte)193, (byte)223, (byte)190, 6, 104, 11, (byte)235, (byte)249, 96, 54, (byte)192, (byte)233, 41, (byte)198, (byte)188, 15, (byte)218, 10, 0, 61, 95, 58, 122, 74, (byte)169, 27, (byte)228, 121, (byte)224, (byte)128, 124, (byte)198, (byte)183, 23, 36, 89, 105, (byte)184, 59, (byte)245, 115, (byte)244, 22, 122, (byte)207, (byte)217, (byte)219, (byte)160, 2, (byte)227, (byte)175, (byte)134, 66, (byte)165, 73, 102, 52, 14, (byte)150, (byte)182, (byte)187, (byte)228, (byte)173, 96, 68, 11, 35, (byte)166, (byte)247, 45, 18, (byte)202, 99, 81, (byte)185, (byte)216, (byte)240, 66, 10, 105, 122, 45, 83};
  
  cipher.init(Cipher.DECRYPT_MODE, key, ivSpec);
  byte[] plaintext = cipher.doFinal(decoded);
  String plaintextString = new String(plaintext, StandardCharsets.UTF_8); 
  
  # Here I expect the value `textToEncrypt` to be decrypted under variable `plaintextString`.
  
  </code></pre>
  <p>Am I doing something wrong? Eg, the way Im setting the counter(IV) in <code>Java</code>.</p>
  <p><strong>FYI info</strong></p>
  <ul>
  <li>cipher.getAlgorithm() is SunJCE version 15</li>
  </ul>