3

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 1

4

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))

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.