Skip to content
Snippets Groups Projects
Commit 26beeaec authored by Marcus Schiesser's avatar Marcus Schiesser
Browse files

added md5 implementation

parent 05f836e8
No related branches found
No related tags found
No related merge requests found
package main
import (
"crypto/md5"
"fmt"
"io"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: gomd5 [file ...]")
}
files := os.Args[1:]
for _, file := range files {
if err := processFile(file); err != nil {
fmt.Fprintf(os.Stderr, "gomd5: %v", err)
}
}
}
func processFile(filename string) error {
f, err := os.Open(filename)
if err != nil {
return err
}
defer f.Close()
h := md5.New()
if _, err := io.Copy(h, f); err != nil {
return err
}
fmt.Printf("%x\n", h.Sum(nil))
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment