rewriting in go

This commit is contained in:
2025-08-11 23:10:30 +02:00
parent bea5baf026
commit 154f058971
23 changed files with 449 additions and 656 deletions

23
tools/tools.go Normal file
View File

@@ -0,0 +1,23 @@
package tools
import (
"encoding/hex"
"fmt"
"hash"
"io"
"github.com/sigurn/crc8"
)
func Hash(h hash.Hash, r io.Reader) (string, error) {
if _, err := io.Copy(h, r); err != nil {
return "", fmt.Errorf("failed to read string: %w", err)
}
return hex.EncodeToString(h.Sum(nil)), nil
}
func CRC8(s []byte, param crc8.Params) string {
table := crc8.MakeTable(param)
crc := crc8.Checksum(s, table)
return fmt.Sprintf("%X", crc)
}