Continue reorganization, add asinkd stop cmd, make asinkd socket configurable

This commit is contained in:
2013-09-02 23:35:48 -04:00
parent 2599717d09
commit 4eb75e1db1
15 changed files with 55 additions and 11 deletions

26
asink/hash.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"crypto/sha256"
"fmt"
"io"
"os"
)
func HashFile(filename string) (string, error) {
//TODO change to sha512?
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
}