Skip to content

Instantly share code, notes, and snippets.

@zph
Created July 7, 2016 08:41
Show Gist options
  • Save zph/76f1ed3a38b57fd939a3c010a0b8a416 to your computer and use it in GitHub Desktop.
Save zph/76f1ed3a38b57fd939a3c010a0b8a416 to your computer and use it in GitHub Desktop.
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")
}
@zph
Copy link
Author

zph commented Jul 7, 2016

Get MD5sum from a file in golang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment