zcrc64

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 (
	ISOTable  = crc64.MakeTable(crc64.ISO)
	ECMATable = crc64.MakeTable(crc64.ECMA)
)

Functions

func EqualSumECMA

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

EqualSumECMA compares CRC64 hash using crc64.ECMA table. It returns if the sum matches to the hash of b.

func EqualSumISO

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

EqualSumISO compares CRC64 hash using crc64.ISO table. It returns if the sum matches to the hash of b.

func SumECMA

func SumECMA(b []byte) []byte

SumECMA returns CRC64 hash using crc64.ECMA table. It uses hash/crc64.New.

Example
package main

import (
	"encoding/hex"
	"fmt"

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

func main() {
	// Calculate CRC64 hash using ECMA table.
	// Validation data can be generated with:
	// 	- https://www.sunshine2k.de/coding/javascript/crc/crc_js.html
	// 	- https://toolkitbay.com/tkb/tool/CRC-64

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

8 85d207c9ff681c7c

func SumISO

func SumISO(b []byte) []byte

SumISO returns CRC64 hash using crc64.ISO table. It uses hash/crc64.New.

Example
package main

import (
	"encoding/hex"
	"fmt"

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

func main() {
	// Calculate CRC64 hash using ISO table.
	// Validation data can be generated with:
	// 	- https://www.sunshine2k.de/coding/javascript/crc/crc_js.html
	// 	- https://toolkitbay.com/tkb/tool/CRC-64

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

8 d22707d9ac3eeee2

Types

This section is empty.

Jump to

Keyboard shortcuts

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