package util

import (
	"hash"
	"hash/crc32"
)

var (
	castagnoliTable = crc32.MakeTable(crc32.Castagnoli)
)

func CalculateCRC32(page []byte) uint32 {
	return crc32.Checksum(page, castagnoliTable)
}

func IsValidChecksum(page []byte, checksum uint32) bool {
	return crc32.Checksum(page, castagnoliTable) == checksum
}

func NewHasher() hash.Hash32 {
	return crc32.New(castagnoliTable)
}
