MCPcopy
hub / github.com/cloudfoundry/cli / Sha1Sum

Function Sha1Sum

integration/helpers/sha.go:13–23  ·  view source on GitHub ↗

Sha1Sum calculates the SHA1 sum of a file.

(path string)

Source from the content-addressed store, hash-verified

11
12// Sha1Sum calculates the SHA1 sum of a file.
13func Sha1Sum(path string) string {
14 f, err := os.Open(path)
15 Expect(err).ToNot(HaveOccurred())
16 defer f.Close()
17
18 hash := sha1.New()
19 _, err = io.Copy(hash, f)
20 Expect(err).ToNot(HaveOccurred())
21
22 return fmt.Sprintf("%x", hash.Sum(nil))
23}

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected