switching everything over to []byte, abandoning merkletree for now

This commit is contained in:
2020-07-01 14:33:01 -04:00
parent e4ac7f70e6
commit 07bbb442ef
12 changed files with 215 additions and 82 deletions

View File

@@ -1,14 +1,18 @@
package engine
import (
"github.com/kalafut/imohash"
"crypto/sha256"
"io/ioutil"
)
// UniqueFileHash creats a fast hash of a file. It's not bullet proof (could cause a collision, but in practice unlikely) but its fast
func UniqueFileHash(src string) ([16]byte, error) {
hash, err := imohash.SumFile(src)
// UniqueFileHash uses SHA256 to create a hash of the file
func UniqueFileHash(src string) ([]byte, error) {
file, err := ioutil.ReadFile(src)
if err != nil {
return [16]byte{}, err
return []byte{}, err
}
hasher := sha256.New()
hasher.Write(file)
hash := hasher.Sum(nil)
return hash, nil
}