Skip to content

Commit 286261d

Browse files
Merge pull request #3 from saj/hash-blake
hash: add blake2b/blake3
2 parents 0c2d7ec + 8d51830 commit 286261d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

hash/hash_test.go

+25-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ 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+
"github.com/zeebo/blake3"
20+
"golang.org/x/crypto/blake2b"
21+
"golang.org/x/crypto/sha3"
1922
)
2023

2124
func benchmarkHashAlgo(b *testing.B, h hash.Hash) {
@@ -33,6 +36,26 @@ func BenchmarkAdler32(b *testing.B) {
3336
benchmarkHashAlgo(b, adler32.New())
3437
}
3538

39+
func BenchmarkBlake2b256(b *testing.B) {
40+
h, err := blake2b.New256(nil)
41+
if err != nil {
42+
b.Fatal(err)
43+
}
44+
benchmarkHashAlgo(b, h)
45+
}
46+
47+
func BenchmarkBlake2b512(b *testing.B) {
48+
h, err := blake2b.New512(nil)
49+
if err != nil {
50+
b.Fatal(err)
51+
}
52+
benchmarkHashAlgo(b, h)
53+
}
54+
55+
func BenchmarkBlake3256(b *testing.B) {
56+
benchmarkHashAlgo(b, blake3.New())
57+
}
58+
3659
func BenchmarkCRC32(b *testing.B) {
3760
benchmarkHashAlgo(b, crc32.NewIEEE())
3861
}

0 commit comments

Comments
 (0)