switching everything over to []byte, abandoning merkletree for now
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user