aboutsummaryrefslogtreecommitdiff
path: root/core/crypt.go
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-02-12 18:55:29 +0100
committeraxtloss <axtlos@getcryst.al>2024-02-12 18:55:29 +0100
commite01c0cf2c84c41841bd7f080a2136c67cf5425b9 (patch)
tree6f7ee71afeb6de4cee55b97fa0a5eb67452ab8cb /core/crypt.go
parentae67ea6a67c25fef305964ee34d4bf96b9da8519 (diff)
downloadfsverify-e01c0cf2c84c41841bd7f080a2136c67cf5425b9.tar.gz
fsverify-e01c0cf2c84c41841bd7f080a2136c67cf5425b9.tar.bz2
Improve performance
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 f741b8e..19a8420 100644
--- a/core/crypt.go
+++ b/core/crypt.go
@@ -2,24 +2,24 @@ package core
import (
"bytes"
- "crypto/sha256"
+ "crypto/sha1"
"fmt"
"io"
"strings"
)
func calculateStringHash(a string) (string, error) {
- hash := sha256.New()
+ hash := sha1.New()
hash.Write([]byte(a))
- hashInBytes := hash.Sum(nil)[:32]
+ hashInBytes := hash.Sum(nil)[:20]
return strings.TrimSpace(fmt.Sprintf("%x", hashInBytes)), nil
}
func CalculateBlockHash(block []byte) (string, error) {
- hash := sha256.New()
+ hash := sha1.New()
if _, err := io.Copy(hash, bytes.NewReader(block)); err != nil {
return "", err
}
- hashInBytes := hash.Sum(nil)[:32]
+ hashInBytes := hash.Sum(nil)[:20]
return strings.TrimSpace(fmt.Sprintf("%x", hashInBytes)), nil
}