Skip to content

Commit 88019fb

Browse files
committed
hash: add blake2b
1 parent 0c2d7ec commit 88019fb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

hash/hash_test.go

+20-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import (
88
"crypto/sha1"
99
"crypto/sha256"
1010
"crypto/sha512"
11-
"github.com/jzelinskie/whirlpool"
12-
"golang.org/x/crypto/sha3"
1311
"hash"
1412
"hash/adler32"
1513
"hash/crc32"
1614
"hash/fnv"
1715
"math/rand"
1816
"testing"
17+
18+
"github.com/jzelinskie/whirlpool"
19+
"golang.org/x/crypto/blake2b"
20+
"golang.org/x/crypto/sha3"
1921
)
2022

2123
func benchmarkHashAlgo(b *testing.B, h hash.Hash) {
@@ -33,6 +35,22 @@ func BenchmarkAdler32(b *testing.B) {
3335
benchmarkHashAlgo(b, adler32.New())
3436
}
3537

38+
func BenchmarkBlake2b256(b *testing.B) {
39+
h, err := blake2b.New256(nil)
40+
if err != nil {
41+
b.Fatal(err)
42+
}
43+
benchmarkHashAlgo(b, h)
44+
}
45+
46+
func BenchmarkBlake2b512(b *testing.B) {
47+
h, err := blake2b.New512(nil)
48+
if err != nil {
49+
b.Fatal(err)
50+
}
51+
benchmarkHashAlgo(b, h)
52+
}
53+
3654
func BenchmarkCRC32(b *testing.B) {
3755
benchmarkHashAlgo(b, crc32.NewIEEE())
3856
}

0 commit comments

Comments
 (0)