Initial Commit

This commit is contained in:
2013-02-10 23:39:23 -05:00
commit 74fd90c850
4 changed files with 205 additions and 0 deletions

21
hash.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"io"
"os"
"fmt"
"crypto/sha256"
)
func HashFile(filename string) (string, error) {
hashfn := sha256.New()
infile, err := os.Open(filename)
if err != nil { return "", err }
defer infile.Close()
_, err = io.Copy(hashfn, infile)
if err != nil { return "", err }
return fmt.Sprintf("%x", hashfn.Sum(nil)), nil
}