title: Javascript Hash Prototype to C#
body: <p>I have a javascript string.prototype that creates a hash for a string.
  JS:</p>
  
  <pre><code>    String.prototype.hashCode = function () {
          var hash = 5381, i = this.length
          while (i)
              hash = (hash * 33) ^ this.charCodeAt(--i)
          return hash &gt;&gt;&gt; 0;
      }
  </code></pre>
  
  <p>I need to recreate this hash in C# for another application that uses the same database. Below is what I have so far...</p>
  
  <pre><code>    public string hashCode(string password)
      {
          var hash = 5381;
          int i;
          string newHash = "";
          int index = password.Length;
          for (i = 0; i &gt; index; i++)
              hash = (hash * 33) ^ (char)password[--index];
          hash = (int)((uint)index &gt;&gt; 0);
          newHash += hash;
          return newHash;
      }
  </code></pre>
  
  <p>If anyone could point me in the right direction, it would be greatly appreciated!</p>
  
  <p>Thanks!</p>