Skip to content

Commit

Permalink
Merge pull request #31 from tinsel-grumble/tinsel-grumble-patch-1
Browse files Browse the repository at this point in the history
add blake2 support
  • Loading branch information
TP Honey committed Jan 18, 2022
2 parents 2087ad8 + f57eb72 commit 6ae63e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"crypto/sha256"
"crypto/sha512"
"fmt"
"golang.org/x/crypto/blake2b"
"golang.org/x/crypto/blake2s"
"hash/adler32"
"hash/crc32"
"io"
Expand Down Expand Up @@ -53,6 +55,10 @@ func checksum(r io.Reader, method string) (string, error) {
return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
case "crc32":
return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
case "blake2b":
return fmt.Sprintf("%x", blake2b.Sum256(b)), nil
case "blake2s":
return fmt.Sprintf("%x", blake2s.Sum256(b)), nil
}

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

0 comments on commit 6ae63e4

Please sign in to comment.