Created
July 7, 2016 08:41
-
-
Save zph/76f1ed3a38b57fd939a3c010a0b8a416 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"crypto/md5" | |
"fmt" | |
"io/ioutil" | |
) | |
func fileMD5(file string) string { | |
fileName := file | |
b, err := ioutil.ReadFile(fileName) | |
if err != nil { | |
fmt.Println(fileName, err) | |
} | |
sum := md5.Sum(b) | |
return fmt.Sprintf("MD5: %x", sum) | |
} | |
func main() { | |
fileMD5("md5.go") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get MD5sum from a file in golang.