MCPcopy Create free account
hub / github.com/drone-plugins/drone-github-release / checksum

Function checksum

utils.go:37–60  ·  view source on GitHub ↗
(r io.Reader, method string)

Source from the content-addressed store, hash-verified

35}
36
37func checksum(r io.Reader, method string) (string, error) {
38 b, err := ioutil.ReadAll(r)
39
40 if err != nil {
41 return "", err
42 }
43
44 switch method {
45 case "md5":
46 return fmt.Sprintf("%x", md5.Sum(b)), nil
47 case "sha1":
48 return fmt.Sprintf("%x", sha1.Sum(b)), nil
49 case "sha256":
50 return fmt.Sprintf("%x", sha256.Sum256(b)), nil
51 case "sha512":
52 return fmt.Sprintf("%x", sha512.Sum512(b)), nil
53 case "adler32":
54 return strconv.FormatUint(uint64(adler32.Checksum(b)), 10), nil
55 case "crc32":
56 return strconv.FormatUint(uint64(crc32.ChecksumIEEE(b)), 10), nil
57 }
58
59 return "", fmt.Errorf("Hashing method %s is not supported", method)
60}
61
62func writeChecksums(files, methods []string, format string, flatten bool) ([]string, error) {
63 checksums := make(map[string][]string)

Callers 1

writeChecksumsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected