HashLocalFile returns the SHA-256 hash of a file's contents.
(path string)
| 23 | |
| 24 | // HashLocalFile returns the SHA-256 hash of a file's contents. |
| 25 | func HashLocalFile(path string) (string, error) { |
| 26 | data, err := os.ReadFile(path) |
| 27 | if err != nil { |
| 28 | return "", err |
| 29 | } |
| 30 | h := sha256.Sum256(data) |
| 31 | return fmt.Sprintf("%x", h[:]), nil |
| 32 | } |
no outgoing calls