I need calculate checksum of a file to determine the integrity of data of existing file. I need it for large files to avoid the download. Can you give me any idea?
1 Answer
You can do that by :
f, err := os.Open(path)
if err != nil {
glog.Fatal(err)
}
defer f.Close()
hasher := sha256.New()
if _, err := io.Copy(hasher, f); err != nil {
glog.Fatal(err)
}
value:= hex.EncodeToString(hasher.Sum(nil))