github.com/Ptt-official-app/go-bbs@v0.12.0/pttbbs/internal/fnv/fnv.go (about) 1 package fnv 2 3 import ( 4 "encoding" 5 "hash" 6 "hash/fnv" 7 ) 8 9 const ( 10 PttFnv32Init uint32 = 33554467 11 ) 12 13 func New32aWith(offset uint32) hash.Hash32 { 14 15 h := fnv.New32a() 16 b, _ := h.(encoding.BinaryMarshaler).MarshalBinary() 17 b[4] = byte((offset >> 24) & 0xFF) 18 b[5] = byte(offset >> 16 & 0xFF) 19 b[6] = byte(offset >> 8 & 0xFF) 20 b[7] = byte(offset & 0xFF) 21 22 h.(encoding.BinaryUnmarshaler).UnmarshalBinary(b) 23 return h 24 }