Skip to content

Commit 6ae63e4

Browse files
author
TP Honey
authored
Merge pull request #31 from tinsel-grumble/tinsel-grumble-patch-1
add blake2 support
2 parents 2087ad8 + f57eb72 commit 6ae63e4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"crypto/sha256"
77
"crypto/sha512"
88
"fmt"
9+
"golang.org/x/crypto/blake2b"
10+
"golang.org/x/crypto/blake2s"
911
"hash/adler32"
1012
"hash/crc32"
1113
"io"
@@ -53,6 +55,10 @@ func checksum(r io.Reader, method string) (string, error) {
5355
return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
5456
case "crc32":
5557
return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
58+
case "blake2b":
59+
return fmt.Sprintf("%x", blake2b.Sum256(b)), nil
60+
case "blake2s":
61+
return fmt.Sprintf("%x", blake2s.Sum256(b)), nil
5662
}
5763

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

0 commit comments

Comments
 (0)