GitPedia

Crc16

Implements the 16-bit cyclic redundancy check, or CRC-16, checksum

From howeyc·Updated April 3, 2025·View on GitHub·

A Go package implementing the 16-bit Cyclic Redundancy Check, or CRC-16, checksum. The project is written primarily in Go, distributed under the BSD 3-Clause "New" or "Revised" License license, first published in 2013. Key topics include: crc, go.

GoDoc Build Status

CRC16

A Go package implementing the 16-bit Cyclic Redundancy Check, or CRC-16, checksum.

Usage

To generate the hash of a byte slice, use the crc16.Checksum() function:

golang
import "github.com/howeyc/crc16" data := byte("test") checksum := crc16.Checksum(data, crc16.IBMTable)

The package provides the following hashing tables. For each of these tables, a shorthand can be used.

golang
// This is the same as crc16.Checksum(data, crc16.IBMTable) checksum := crc16.ChecksumIBM(data)

Using the hash.Hash interface also works.

go
h := crc16.New(crc16.IBMTable) data := byte("test") data2 := byte("data") h.Write(data) h.Write(data2) checksum := h.Sum(nil)

Changelog

  • 2017.03.27 - Added MBus checksum
  • 2017.05.27 - Added checksum function without XOR
  • 2017.12.08 - Implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to allow saving and recreating their internal state.

Contributors

Showing top 4 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from howeyc/crc16 via the GitHub API.Last fetched: 6/25/2026