title: Modified FNV-1 hash algorithm in golang
body: <p>Native library has FNV-1 hash algorithm <a href="https://golang.org/pkg/hash/fnv/" rel="nofollow">https://golang.org/pkg/hash/fnv/</a> that returns uint64 value (range: 0 through 18446744073709551615).
  I need to store this value in PostgreSQL bigserial, but it's range is 1 to 9223372036854775807.</p>
  
  <p>It is possible to change hash size to eg. 56?<a href="http://www.isthe.com/chongo/tech/comp/fnv/index.html#xor-fold" rel="nofollow">http://www.isthe.com/chongo/tech/comp/fnv/index.html#xor-fold</a></p>
  
  <p>Can someone help to change native algorithm to produce 56 bit hashes?
  <a href="https://golang.org/src/hash/fnv/fnv.go" rel="nofollow">https://golang.org/src/hash/fnv/fnv.go</a></p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Did it myself using this doc <a href="http://www.isthe.com/chongo/tech/comp/fnv/index.html#xor-fold" rel="nofollow">http://www.isthe.com/chongo/tech/comp/fnv/index.html#xor-fold</a></p>
  
  <pre class="lang-go prettyprint-override"><code>package main
  
  import (
      "fmt"
      "hash/fnv"
  )
  
  func main() {
      const MASK uint64 = 1&lt;&lt;63 - 1
      h := fnv.New64()
      h.Write([]byte("1133"))
      hash := h.Sum64()
      fmt.Printf("%#x\n", MASK)
      fmt.Println(hash)
      hash = (hash &gt;&gt; 63) ^ (hash &amp; MASK)
      fmt.Println(hash)
  }
  </code></pre>
  
  <p><a href="http://play.golang.org/p/j7q3D73qqu" rel="nofollow">http://play.golang.org/p/j7q3D73qqu</a></p>
  
  <p>Is it correct?</p>