You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
322 B

  1. package storage
  2. import (
  3. "hash/crc32"
  4. )
  5. var table = crc32.MakeTable(crc32.Castagnoli)
  6. type CRC uint32
  7. func NewCRC(b []byte) CRC {
  8. return CRC(0).Update(b)
  9. }
  10. func (c CRC) Update(b []byte) CRC {
  11. return CRC(crc32.Update(uint32(c), table, b))
  12. }
  13. func (c CRC) Value() uint32 {
  14. return uint32(c>>15|c<<17) + 0xa282ead8
  15. }