title: byte to string and vice versa
body: <p>I need to convert a salt value randomly generated and store it in the database. To store it in the database I converted it to a string. Then for retrieving the original value, I convert it back to byte. But both value are not matching. I have tried "UTF-8","UTF-16", BASE64Encoder.</p>
  
  <pre><code>SecureRandom ranGen = new SecureRandom();
  byte[] aesKey = new byte[16]; // 16 bytes = 128 bits
  ranGen.nextBytes(aesKey);   
  System.out.println(aesKey);
  
  String a=new String(aesKey,"UTF-16");
  byte[] b=new byte[16];
  b=a.getBytes("UTF-16");
  System.out.println(b);
  </code></pre>
  
  <p>Outputs for the above code(Executed it 2 times):</p>
  
  <pre><code>[B@11563ff
  [B@1581593
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[B@170888e
  [B@11563ff
  </code></pre>