Answers for "golang get file sha256"

Go
0

golang get file sha256

f, err := os.Open("path/to/file")
if err != nil {
	log.Fatal(err)
}

defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
	log.Fatal(err)
}
fmt.Printf("%x", h.Sum(nil))
Posted by: Guest on July-06-2020

Browse Popular Code Answers by Language