Skip to content

Instantly share code, notes, and snippets.

@inkel
Created February 16, 2015 21:56
Show Gist options
  • Save inkel/9993fa6f8c12c81af113 to your computer and use it in GitHub Desktop.
Save inkel/9993fa6f8c12c81af113 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/howeyc/crc16"
)
func main() {
data := []byte("inkel")
fmt.Println(data)
// 17 because http://en.wikipedia.org/wiki/Cyclic_redundancy_check#Designing_polynomials
table := crc16.MakeTable(17)
crc := crc16.Checksum(data, table)
fmt.Printf("%0X [%v]\n", crc, crc)
h := crc >> 8
l := crc & 0xff
fmt.Printf("HL: %0X %0X\n", h, l)
fmt.Printf("LH: %0X %0X\n", l, h)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment