title: cryptojs: How to generate AES passphrase
body: <p>I want to generate a 256bit password for my AES encryption. When I check the password after the encryption  it is different from my initial password. What am I doing wrong? Or is there some security mechanism I am not aware of?</p>
  
  <p>My code:</p>
  
  <pre><code>password=Generate_key();
  
  var encrypted = CryptoJS.AES.encrypt("Message", password);
  
  //Those two should be the same
  document.write(password+"&lt;br&gt;");
  document.write(encrypted.key);
  
  
  function Generate_key() {
      var key = "";
      var hex = "0123456789abcdef";
  
      for (i = 0; i &lt; 64; i++) {
          key += hex.charAt(Math.floor(Math.random() * 16));
          //Initially this was charAt(chance.integer({min: 0, max: 15}));
      }
      return key;
  }
  </code></pre>
  
  <p>The output is i.e.</p>
  
  <blockquote>
    <p>0b05308c9a00f07044416bad7a51bacd282fc5c0c999551a4ff15c302b268b20
    4df875993770411044fb35953166ee7833c32ca0741e9fec091dfa10138039e8</p>
  </blockquote>
  
  <p>Is this normal or am I doing something wrong here?
  Thanks for help!</p>