Hello! I’m attempting to get the output of a crc32 to match the outcome from zlib and can’t determine the proper inputs to take action. The reply to this SO has an instance utilization of zlib in Python that I’m attempting to copy in Go.
I’ve this at the moment:
desk := crc32.MakeTable(0xb71dc104)
outcome := crc32.Replace(0xFFFFFFFF, desk, []byte(“123456789”))
outcome ^= 0xFFFFFFFF
The polynomial that zlib makes use of is 0x04C11DB7 however the go docs counsel that it expects reversed order. I may need carried out that unsuitable? I’ve tried little endian and massive endian and all mixtures of unique ors that I can consider. I’ve additionally tried crc64 after which casting again down. It’s gotta be one thing easy however I simply haven’t been capable of replicate it! Any concepts??
Thanks!
Hello @thenorthnate, how are you?
crc32.IEEE is your desk
right here is an instance:
package deal most important
import (
"fmt"
"hash/crc32"
)
func most important() {
knowledge := []byte("123456789")
desk := crc32.MakeTable(crc32.IEEE)
bought := crc32.Checksum(knowledge, desk)
fmt.Printf("bought: %08xn", bought)
fmt.Println("-- OR --")
outcome := crc32.Replace(0, desk, knowledge)
fmt.Printf("outcome: %08xn", outcome)
}
bought: cbf43926
– OR –
outcome: cbf43926