title: How to replicate java's ByteBuffer.putLong in php?
body: <p>I need to access from php data from a mysql database whose content is set by a java application, in order to calculate the correct user hash.</p>
  
  <p>I can't seem to replicate the code using php, and I think my problem lies with the long value that PHP can't handle as far as I know</p>
  
  <p>What I have so far:</p>
  
  <pre><code>&lt;?php
  $g_salt = 'the global salt';
  $u_salt = "-2413991061102778232";
  $pass = "the password";
  
  $tmp = '';
  for ($i = 0; $i &lt; strlen($u_salt); $i++) {
   $tmp .= ord($u_salt[$i]);
  }
  $u_salt = $tmp;
  
  $buffer = $g_salt.$u_salt.$pass;
  $hash = bin2hex(mhash(MHASH_SHA256, $buffer));
  
  var_dump($hash);
  var_dump("1ee103abe2595681d35c11a27f6dc03a02c5a6ebe01f8abcd7d634a25e050b49");
  </code></pre>
  
  <p>Any idea of how I could do to fix my code ? Thanks a lot in advance</p>