Extract filesmap to own file

This commit is contained in:
jacob1123 committed 2020-11-21 22:14:42 +01:00
1 parent 8a9bcbf62e
commit 87c8a6e817
3 files changed
+85 -82

No files matched your search

+18
View File
@@ -1,6 +1,9 @@
package main
import (
"crypto/sha256"
"encoding/base64"
"io"
"os"
"path/filepath"
"strconv"
@@ -37,3 +40,18 @@ func moveButDontOvewrite(path string, targetPath string) {
num++
}
}
func calculateHash(path string) (string, error) {
f, err := os.Open(path)
if err != nil {
return "", err
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return "", err
}
return base64.RawStdEncoding.EncodeToString(h.Sum(nil)), nil
}