aboutsummaryrefslogtreecommitdiff
path: root/core/crypt.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/crypt.go')
-rw-r--r--core/crypt.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/crypt.go b/core/crypt.go
index 6de70e6..f741b8e 100644
--- a/core/crypt.go
+++ b/core/crypt.go
@@ -1,25 +1,25 @@
package core
import (
+ "bytes"
"crypto/sha256"
"fmt"
"io"
- "os"
"strings"
)
func calculateStringHash(a string) (string, error) {
hash := sha256.New()
hash.Write([]byte(a))
- hashInBytes := hash.Sum(nil)[:20]
+ hashInBytes := hash.Sum(nil)[:32]
return strings.TrimSpace(fmt.Sprintf("%x", hashInBytes)), nil
}
-func calculateFileHash(file *os.File) (string, error) {
+func CalculateBlockHash(block []byte) (string, error) {
hash := sha256.New()
- if _, err := io.Copy(hash, file); err != nil {
+ if _, err := io.Copy(hash, bytes.NewReader(block)); err != nil {
return "", err
}
- hashInBytes := hash.Sum(nil)[:20]
+ hashInBytes := hash.Sum(nil)[:32]
return strings.TrimSpace(fmt.Sprintf("%x", hashInBytes)), nil
}