20 lines
325 B
Go
20 lines
325 B
Go
package videofile
|
|
|
|
import (
|
|
"crypto/sha1"
|
|
"encoding/hex"
|
|
"os"
|
|
)
|
|
|
|
func GetHashFromPath(path string) (string, error) {
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
h := sha1.New()
|
|
h.Write([]byte(path))
|
|
h.Write([]byte(info.ModTime().String()))
|
|
sha := hex.EncodeToString(h.Sum(nil))
|
|
return sha, nil
|
|
}
|