54 lines
1.4 KiB
Markdown
Raw Normal View History

2023-07-22 12:56:33 +00:00
# hash
2023-07-23 19:07:52 +00:00
This is a non-cryptographic hash (aka checksum) to verify data integrity.
2023-10-20 13:38:00 +00:00
## Installation
```shell
go get git.akyoto.dev/go/hash
```
## Usage
2023-07-23 19:07:52 +00:00
```go
sum := hash.Bytes(data)
```
2023-07-23 19:16:37 +00:00
You can use `strconv.FormatUint(sum, 16)` to get a string in hexadecimal format.
2023-10-20 13:38:00 +00:00
## Tests
```
PASS: TestTiny
PASS: TestZeroed
PASS: TestSameByte
PASS: TestDistribution
coverage: 100.0% of statements
```
2023-07-23 19:16:37 +00:00
## Benchmarks
```
2024-06-18 14:17:02 +00:00
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
2023-10-20 13:38:00 +00:00
```
## License
Please see the [license documentation](https://akyoto.dev/license).
## Copyright
© 2023 Eduard Urbach