gitee.com/gricks/utils@v1.0.8/crc32.go (about) 1 package utils 2 3 import ( 4 "hash/crc32" 5 ) 6 7 var crc32Table = crc32.MakeTable(crc32.Castagnoli) 8 9 type CRC uint32 10 11 func NewCRC(b []byte) CRC { 12 return CRC(0).Append(b) 13 } 14 15 func (c CRC) Append(b []byte) CRC { 16 return CRC(crc32.Update(uint32(c), crc32Table, b)) 17 } 18 19 func (c CRC) Value() uint32 { 20 return uint32(c>>15|c<<17) + 0xa282ead8 21 }