Add a simple sha3sum utility.
parent
dd21e91ec1
commit
e7f1f3541f
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue