Add a simple sha3sum utility.

master
magical 2014-12-31 23:32:14 -08:00
parent dd21e91ec1
commit e7f1f3541f
1 changed files with 33 additions and 0 deletions

33
sha3sum/main.go 100644
View File

@ -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)
}
}