19 lines
334 B
Go
19 lines
334 B
Go
package engine
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"io/ioutil"
|
|
)
|
|
|
|
// 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 []byte{}, err
|
|
}
|
|
hasher := sha256.New()
|
|
hasher.Write(file)
|
|
hash := hasher.Sum(nil)
|
|
return hash, nil
|
|
}
|