54 lines
1.4 KiB
Markdown
Raw Normal View History

2023-07-22 12:56:33 +00:00
# hash
2023-07-23 21:07:52 +02:00
This is a non-cryptographic hash (aka checksum) to verify data integrity.
2023-10-20 15:38:00 +02:00
## Installation
```shell
go get git.akyoto.dev/go/hash
```
## Usage
2023-07-23 21:07:52 +02:00
```go
sum := hash.Bytes(data)
```
2023-07-23 21:16:37 +02:00
You can use `strconv.FormatUint(sum, 16)` to get a string in hexadecimal format.
2023-10-20 15:38:00 +02:00
## Tests
```
PASS: TestTiny
PASS: TestZeroed
PASS: TestSameByte
PASS: TestDistribution
coverage: 100.0% of statements
```
2023-07-23 21:16:37 +02:00
## Benchmarks
```
BenchmarkSize/___8-12 318401613 3.779 ns/op
BenchmarkSize/__16-12 273568264 4.400 ns/op
BenchmarkSize/__17-12 222336567 5.425 ns/op
BenchmarkSize/__32-12 191413396 6.266 ns/op
BenchmarkSize/__33-12 167791207 7.064 ns/op
BenchmarkSize/__64-12 224622992 5.320 ns/op
BenchmarkSize/__65-12 211713483 5.735 ns/op
BenchmarkSize/_128-12 137411010 8.735 ns/op
BenchmarkSize/_256-12 58641082 20.34 ns/op
BenchmarkSize/_512-12 22842753 54.89 ns/op
BenchmarkSize/1024-12 8913499 134.5 ns/op
BenchmarkSize/2048-12 4074927 294.5 ns/op
BenchmarkSize/4096-12 1952067 625.4 ns/op
2023-10-20 15:38:00 +02:00
```
## License
Please see the [license documentation](https://akyoto.dev/license).
## Copyright
© 2023 Eduard Urbach