🔢 Non-cryptographic hash to verify data integrity. 9 Commits
2024-06-18 16:17:02 +02:00
.gitignore Cleanup 2023-10-20 15:38:00 +02:00
Benchmarks_test.go Cleanup 2023-10-20 15:38:00 +02:00
go.mod Improved hash distribution 2024-06-18 16:17:02 +02:00
hash_test.go Improved hash distribution 2024-06-18 16:17:02 +02:00
hash.go Improved hash distribution 2024-06-18 16:17:02 +02:00
README.md Improved hash distribution 2024-06-18 16:17:02 +02:00

hash

This is a non-cryptographic hash (aka checksum) to verify data integrity.

Installation

go get git.akyoto.dev/go/hash

Usage

sum := hash.Bytes(data)

You can use strconv.FormatUint(sum, 16) to get a string in hexadecimal format.

Tests

PASS: TestTiny
PASS: TestZeroed
PASS: TestSameByte
PASS: TestDistribution
coverage: 100.0% of statements

Benchmarks

BenchmarkSize/___8-12           290052092                4.157 ns/op
BenchmarkSize/__16-12           193105472                6.202 ns/op
BenchmarkSize/__17-12           147168594                8.195 ns/op
BenchmarkSize/__32-12           151655024                7.876 ns/op
BenchmarkSize/__33-12           123326216                9.781 ns/op
BenchmarkSize/__64-12           228098743                5.058 ns/op
BenchmarkSize/__65-12           177117915                6.780 ns/op
BenchmarkSize/_128-12           136319786                8.796 ns/op
BenchmarkSize/_256-12           58794831                20.53 ns/op
BenchmarkSize/_512-12           21937956                54.50 ns/op
BenchmarkSize/1024-12            8905921               134.9 ns/op
BenchmarkSize/2048-12            4063292               295.1 ns/op
BenchmarkSize/4096-12            1947091               617.6 ns/op

License

Please see the license documentation.

© 2023 Eduard Urbach