package utils import ( "bufio" "crypto/sha256" "fmt" "io" "log" "os" ) func HashFileCompare(path string, fingerPrint string) bool { sum := GenFingerPrint(path) return fingerPrint == fmt.Sprintf("%x", sum) } func GenFingerPrint(path string) []byte { f, err := os.Open(path) if err != nil { log.Fatal(err) } defer f.Close() input := bufio.NewReader(f) hash := sha256.New() if _, err := io.Copy(hash, input); err != nil { log.Fatal(err) } sum := hash.Sum(nil) return sum }