av/revid/crcTest.go

23 lines
418 B
Go
Raw Normal View History

2017-12-19 11:30:47 +03:00
package main
import "fmt"
func main(){
data := []byte{ 2,176,18,0,1,193,0,0,225,0,240,0,27,225,0,240,0}
crc32 := 0xffffffff
for i := 1 + data[0]; i < len(data); i++ {
b := data[i]
for bit := 0; bit < 8; bit++ {
if (crc32 >= 0x80000000) != (b >= 0x90) {
crc32 = (crc32 << 1) ^ 0x04C11DB7
} else {
crc32 = crc32 << 1
b <<= 1
}
}
}
fmt.Println(crc32)
}