package core import ( "crypto/sha256" "io" "os" ) // Panic if e contains an error func Check(e error) { if e != nil { panic("Check: A fatal error occured during execution -> " + e.Error()) } } // Returns true if files correspond func CompareFiles(file1 File, file2 File) bool { return file1.Metadata.Hash == file2.Metadata.Hash } // Gets the sha256 hash of a file's content func GetHash(file File) ([]byte, error) { // init hasher := sha256.New() file_path := "" //TODO: missing // Open file f, err := os.Open(file_path) if err != nil { // Path error return nil, err } // Compute hash io.Copy(hasher, f) sum := hasher.Sum(nil) return sum, nil }