Wednesday, May 15, 2024
HomeGolangCompute the identical crc as zlib - Getting Assist

Compute the identical crc as zlib – Getting Assist


Hello! I’m attempting to get the output of a crc32 to match the end result 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 duplicate in Go.

I’ve this at the moment:

desk := crc32.MakeTable(0xb71dc104)
end result := crc32.Replace(0xFFFFFFFF, desk, []byte(“123456789”))
end result ^= 0xFFFFFFFF

The polynomial that zlib makes use of is 0x04C11DB7 however the go docs counsel that it expects reversed order. I may need executed that improper? 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 :smiley:
right here is an instance:

package deal major

import (
	"fmt"
	"hash/crc32"
)

func major() {
	information := []byte("123456789")
	desk := crc32.MakeTable(crc32.IEEE)

	obtained := crc32.Checksum(information, desk)
	fmt.Printf("obtained: %08xn", obtained)

	fmt.Println("-- OR --")

	end result := crc32.Replace(0, desk, information)
	fmt.Printf("end result: %08xn", end result)
}

obtained: cbf43926
– OR –
end result: cbf43926

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments