title: Different hashes with same input values
body: <p>I'm building a api and I'm having trouble generating a hash with CryptoJs in the client-side interface</p>
  
  <p>My js function does this:</p>
  
  <pre><code>console.log(" username: '" + $rootScope.username + "'");
  console.log("timestamp: '" + timestamp + "'");  
  console.log("  request: '" + req + "'");
  console.log("  entropy: '" + "dragonsahead" + "'");
  console.log(" password: '" + $rootScope.password + "'");
  var message = $rootScope.username+timestamp+req+"dragonsahead";
  console.log("  message: '" + message +"'");
  var hash = CryptoJS.HmacSHA1(message, $rootScope.password).toString();
  console.log("     HASH: '" + hash + "'");
  return hash;
  </code></pre>
  
  <p><code>$rootScope.username</code> and <code>$rootScope.password</code> are user inputs;</p>
  
  <p>JS Log:</p>
  
  <pre><code> username: 'admin' 
  timestamp: '1394643128.478' 
    request: '/login' 
    entropy: 'dragonsahead' 
   password: 'e1a47a0407d876c8187b1e984a6813abde8160af' 
    message: 'admin1394643128.478/logindragonsahead' 
       HASH: '5061875265279c7378c95c9536feade1c610492d' 
  </code></pre>
  
  <p>I could see in the server-side logs that the hashes did not match.
  PHP server Log:</p>
  
  <pre><code>2014-03-12 16:52:08 - INFO --&gt;  username: 'admin' 
  2014-03-12 16:52:08 - INFO --&gt; timestamp: '1394643128.478' 
  2014-03-12 16:52:08 - INFO --&gt;   request: '/login' 
  2014-03-12 16:52:08 - INFO --&gt;   entropy: 'dragonsahead' 
  2014-03-12 16:52:08 - INFO --&gt;  password: 'e1a47a0407d876c8187b1e984a6813abde8160af' 
  2014-03-12 16:52:08 - INFO --&gt;   message: 'admin1394643128.478/logindragonsahead' 
  2014-03-12 16:52:08 - INFO --&gt;      HASH: '4c34a29aa05059d5016bd74796407de3d2e5428c' 
  2014-03-12 16:52:08 - INFO --&gt;CLIENTOKEN: '5061875265279c7378c95c9536feade1c610492d'
  </code></pre>
  
  <p>After this I checked i <a href="http://www.freeformatter.com/hmac-generator.htm" rel="nofollow">this site</a> and the hash built by the server was the right one.
  So, I decided lo load CryptoJS to a blank page (google, for example) and see what could happen:</p>
  
  <pre><code>&gt; var jq = document.createElement('script');
  &gt; jq.src = "https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js";
  &gt; document.getElementsByTagName('head')[0].appendChild(jq);
  &lt;script src=​"https:​/​/​crypto-js.googlecode.com/​svn/​tags/​3.1.2/​build/​rollups/​hmac-sha1.js"&gt;​&lt;/script&gt;​
  &gt;var test = CryptoJS.HmacSHA1("admin1394643128.478/logindragonsahead",'e1a47a0407d876c8187b1e984a6813abde8160af')
  undefined
  &gt;test.toString()
  "4c34a29aa05059d5016bd74796407de3d2e5428c"
  </code></pre>
  
  <p>As CryptoJS returned the right hash, It can only be that I am messing up with my javascript vars. I don't know what could possibly be messing up my variables...</p>