Created
February 20, 2015 23:05
-
-
Save sthorne/a42870b0a5ee5f1f28b1 to your computer and use it in GitHub Desktop.
Go - SHA256 File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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