Skip to content

bodgit/crc32

Repository files navigation

GitHub release Build Status Coverage Status Go Report Card GoDoc Go version Go version

crc32

An implementation of an algorithm to modify a file so that its CRC-32 checksum matches a given value. This requires four sacrificial bytes in the file that will be modified to generate the desired value. A small example:

f, err := os.OpenFile("somefile", O_RDWR, 0) // Remember to open read/write!
if err != nil {
        log.Fatal(err)
}
defer f.Close()

if err := crc32.ForceCRC32(f, 0, 0xdeadbeef); err != nil {
        log.Fatal(err)
}

In this example the first four bytes in somefile will be modified so that the CRC-32 checksum of somefile will be 0xdeadbeef however the bytes can be anywhere in the file, but must be contiguous.