Skip to content

Instantly share code, notes, and snippets.

@sthorne
Created February 20, 2015 23:05
Show Gist options
  • Save sthorne/a42870b0a5ee5f1f28b1 to your computer and use it in GitHub Desktop.
Save sthorne/a42870b0a5ee5f1f28b1 to your computer and use it in GitHub Desktop.
Go - SHA256 File
package main
import (
"fmt"
"io/ioutil"
"encoding/hex"
"crypto/sha256"
)
func main() {
f, e := ioutil.ReadFile("file.txt")
if e != nil {
panic(e)
}
h := sha256.New()
h.Write(f)
b := h.Sum(nil)
fmt.Println(hex.EncodeToString(b))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment