From e7f1f3541fc94fd9b323be2cfe68a8ad3363aae0 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Wed, 31 Dec 2014 23:32:14 -0800 Subject: [PATCH] Add a simple sha3sum utility. --- sha3sum/main.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sha3sum/main.go diff --git a/sha3sum/main.go b/sha3sum/main.go new file mode 100644 index 0000000..63127a6 --- /dev/null +++ b/sha3sum/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "flag" + "fmt" + "io" + "os" + + "github.com/magical/keccak" +) + +func main() { + flag.Parse() + var sum [keccak.Size]byte + h := keccak.New256() + files := flag.Args() + for _, filename := range files { + f, err := os.Open(filename) + if err != nil { + fmt.Fprintln(os.Stderr, err) + continue + } + h.Reset() + _, err = io.Copy(h, f) + f.Close() + if err != nil { + fmt.Fprintln(os.Stderr, err) + continue + } + h.Sum(sum[:0]) + fmt.Printf("%x %s\n", sum, filename) + } +}