title: How to generate unique but consistent N-bit hash (less than 64 bit) for strings?
body: <p>I want following mechanism:</p>
  
  <pre><code>int64_t MyHash (const std::string&amp; value);
  </code></pre>
  
  <ul>
  <li>Give any <code>std::string</code> (usually 100 bytes) as an input</li>
  <li>The function outputs a 64-bit integer value</li>
  <li>However the maximum value represented by that integer should be in the range of <code>-2&lt;sup&gt;53&lt;/sup&gt; to 2&lt;sup&gt;53&lt;/sup&gt;-1</code></li>
  </ul>
  
  <p>I tried using <code>std::hash()</code>; The problem with that is: It's different on every platform. Not only that, with every run it differs.  </p>
  
  <p>Currently, using <code>Qt</code>'s <code>QCryptographicHash</code> I am getting an <code>SHA256</code> checksum and that I am truncating to 64-bit. Even in this truncation, also the collision possibility will increase.<br>
  Anyhow, my goal is to get that value within 54 bits. One obvious solution is to divide that number by 2048.</p>
  
  <p><strong>Question</strong>: Is there any better solution to get a hash of 54-bit?<br>
  Javascript solution is also fine.</p>
  
  <p><strong>Purpose</strong>: This value is passed to Javascript. Now it's datatype <code>number</code> can hold a 64-bit double, which is of 54 bits.</p>