1 // Copyright 2011 The LevelDB-Go Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
12 var table = crc32.MakeTable(crc32.Castagnoli)
14 // CRC is a CRC-32 checksum computed using Castagnoli's polynomial.
17 // NewCRC creates a new crc based on the given bytes.
18 func NewCRC(b []byte) CRC {
19 return CRC(0).Update(b)
22 // Update updates the crc with the given bytes.
23 func (c CRC) Update(b []byte) CRC {
24 return CRC(crc32.Update(uint32(c), table, b))
27 // Value returns a masked crc.
28 func (c CRC) Value() uint32 {
29 return uint32(c>>15|c<<17) + 0xa282ead8