This commit is contained in:
Eduard Urbach 2023-10-20 15:38:00 +02:00
parent 30c46352b0
commit 9bbff2e6ed
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
6 changed files with 31 additions and 29 deletions

View File

@ -1,9 +0,0 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

10
.gitignore vendored
View File

@ -1,9 +1,7 @@
* *
!*/ !*/
!.gitignore
!.editorconfig
!go.sum
!go.mod
!README.md
!LICENSE
!*.go !*.go
!*.mod
!*.sum
!*.md
!.gitignore

View File

@ -8,7 +8,6 @@ import (
) )
func BenchmarkSize(b *testing.B) { func BenchmarkSize(b *testing.B) {
b.Run(" 7", bench(7))
b.Run(" 8", bench(8)) b.Run(" 8", bench(8))
b.Run(" 16", bench(16)) b.Run(" 16", bench(16))
b.Run(" 17", bench(17)) b.Run(" 17", bench(17))

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) 2023 Eduard Urbach
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -2,7 +2,13 @@
This is a non-cryptographic hash (aka checksum) to verify data integrity. This is a non-cryptographic hash (aka checksum) to verify data integrity.
## API ## Installation
```shell
go get git.akyoto.dev/go/hash
```
## Usage
```go ```go
sum := hash.Bytes(data) sum := hash.Bytes(data)
@ -10,10 +16,19 @@ sum := hash.Bytes(data)
You can use `strconv.FormatUint(sum, 16)` to get a string in hexadecimal format. 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 ## Benchmarks
``` ```
BenchmarkSize/___7-12 144845362 8.282 ns/op
BenchmarkSize/___8-12 318401613 3.779 ns/op BenchmarkSize/___8-12 318401613 3.779 ns/op
BenchmarkSize/__16-12 273568264 4.400 ns/op BenchmarkSize/__16-12 273568264 4.400 ns/op
BenchmarkSize/__17-12 222336567 5.425 ns/op BenchmarkSize/__17-12 222336567 5.425 ns/op
@ -28,3 +43,11 @@ BenchmarkSize/1024-12 8913499 134.5 ns/op
BenchmarkSize/2048-12 4074927 294.5 ns/op BenchmarkSize/2048-12 4074927 294.5 ns/op
BenchmarkSize/4096-12 1952067 625.4 ns/op BenchmarkSize/4096-12 1952067 625.4 ns/op
``` ```
## License
Please see the [license documentation](https://akyoto.dev/license).
## Copyright
© 2023 Eduard Urbach

2
go.mod
View File

@ -1,3 +1,3 @@
module git.akyoto.dev/go/hash module git.akyoto.dev/go/hash
go 1.20 go 1.21