zcrc32

package
v0.0.0-alpha.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	IEEETable       = crc32.IEEETable
	CastagnoliTable = crc32.MakeTable(crc32.Castagnoli)
	KoopmanTable    = crc32.MakeTable(crc32.Koopman)
)

Functions

func EqualSumCastagnoli

func EqualSumCastagnoli(b []byte, sum []byte) bool

EqualSumECMA compares CRC32 hash using crc32.Castagnoli table. It returns if the sum matches to the hash of b.

func EqualSumIEEE

func EqualSumIEEE(b []byte, sum []byte) bool

EqualSumIEEE compares CRC32 hash using crc32.IEEE table. It returns if the sum matches to the hash of b.

func EqualSumKoopman

func EqualSumKoopman(b []byte, sum []byte) bool

EqualSumECMA compares CRC32 hash using crc32.Koopman table. It returns if the sum matches to the hash of b.

func SumCastagnoli

func SumCastagnoli(b []byte) []byte

SumCastagnoli returns CRC32 hash using crc32.Castagnoli table. It uses hash/crc32.New.

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/aileron-projects/go/zhash/zcrc32"
)

func main() {
	// Calculate CRC32 hash using [crc32.Castagnoli] table.
	// Validation data can be generated with:
	// 	- https://www.sunshine2k.de/coding/javascript/crc/crc_js.html
	// 	- https://crccalc.com/?crc=Hello%20Go!&method=CRC-32&datatype=ascii&outtype=hex

	sum := zcrc32.SumCastagnoli([]byte("Hello Go!"))
	encoded := hex.EncodeToString(sum)
	fmt.Println(len(sum), encoded)
}
Output:

4 c83c2422

func SumIEEE

func SumIEEE(b []byte) []byte

SumIEEE returns CRC32 hash using crc32.IEEE table. It uses hash/crc32.New.

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/aileron-projects/go/zhash/zcrc32"
)

func main() {
	// Calculate CRC32 hash using [crc32.IEEE] table.
	// Validation data can be generated with:
	// 	- https://www.sunshine2k.de/coding/javascript/crc/crc_js.html
	// 	- https://crccalc.com/?crc=Hello%20Go!&method=CRC-32&datatype=ascii&outtype=hex

	sum := zcrc32.SumIEEE([]byte("Hello Go!"))
	encoded := hex.EncodeToString(sum)
	fmt.Println(len(sum), encoded)
}
Output:

4 48e1410f

func SumKoopman

func SumKoopman(b []byte) []byte

SumKoopman returns CRC32 hash using crc32.Koopman table. It uses hash/crc32.New.

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/aileron-projects/go/zhash/zcrc32"
)

func main() {
	sum := zcrc32.SumKoopman([]byte("Hello Go!"))
	encoded := hex.EncodeToString(sum)
	fmt.Println(len(sum), encoded)
}
Output:

4 1f83620a

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL