mirror of
https://github.com/thegeeklab/wp-gitea-release.git
synced 2024-11-24 13:00:40 +00:00
Merge pull request #31 from tinsel-grumble/tinsel-grumble-patch-1
add blake2 support
This commit is contained in:
commit
6ae63e4434
6
utils.go
6
utils.go
@ -6,6 +6,8 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/crypto/blake2b"
|
||||||
|
"golang.org/x/crypto/blake2s"
|
||||||
"hash/adler32"
|
"hash/adler32"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"io"
|
"io"
|
||||||
@ -53,6 +55,10 @@ func checksum(r io.Reader, method string) (string, error) {
|
|||||||
return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
|
return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
|
||||||
case "crc32":
|
case "crc32":
|
||||||
return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
|
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)
|
return "", fmt.Errorf("Hashing method %s is not supported", method)
|
||||||
|
Loading…
Reference in New Issue
Block a user