Restructured to have subpackages, added server communication

This commit is contained in:
2013-02-20 23:43:01 -05:00
parent b193814371
commit 3fc3e3a963
10 changed files with 201 additions and 35 deletions

25
client/hash.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"crypto/sha256"
"fmt"
"io"
"os"
)
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
}