MCPcopy
hub / github.com/slimtoolkit/slim / hashFile

Function hashFile

pkg/appbom/gobinhasher.go:61–75  ·  view source on GitHub ↗
(fullPath string)

Source from the content-addressed store, hash-verified

59}
60
61func hashFile(fullPath string) (string, error) {
62 file, err := os.Open(fullPath)
63 if err != nil {
64 return "", err
65 }
66 defer file.Close()
67
68 hasher := sha256.New()
69 if _, err := io.Copy(hasher, file); err != nil {
70 return "", err
71 }
72
73 hash := hasher.Sum(nil)
74 return fmt.Sprintf("%x", hash), nil
75}

Callers 1

mainFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected