Hi guys,
this is day 18 out of 100 days of code.
To get md5 sum of a file you crypto/md5 library and io/ioutil for reading files.
package main import ( "crypto/md5" "fmt" "io/ioutil" "log" "os" ) func main() { if len(os.Args) <= 1 { log.Fatal("expected filename as parameter") } filename := os.Args[1] data, err := ioutil.ReadFile(filename) if err != nil { log.Fatal(err) } fmt.Printf("MD5 (%s) = %x\n", filename, md5.Sum(data)) }
Thanks!