Skip to content

Commit b0a00e0

Browse files
author
tinsel-grumble
authored
add blake2 hash
1 parent 2087ad8 commit b0a00e0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import (
55
"crypto/sha1"
66
"crypto/sha256"
77
"crypto/sha512"
8+
"crypto/blake2b"
89
"fmt"
10+
"golang.org/x/crypto/blake2b"
11+
"golang.org/x/crypto/blake2s"
912
"hash/adler32"
1013
"hash/crc32"
1114
"io"
@@ -53,6 +56,10 @@ func checksum(r io.Reader, method string) (string, error) {
5356
return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
5457
case "crc32":
5558
return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
59+
case "blake2b":
60+
return fmt.Sprintf("%x", blake2b.Sum256(b)), nil
61+
case "blake2s":
62+
return fmt.Sprintf("%x", blake2s.Sum256(b)), nil
5663
}
5764

5865
return "", fmt.Errorf("Hashing method %s is not supported", method)

0 commit comments

Comments
 (0)