diff options
Diffstat (limited to 'core/crypt.go')
-rw-r--r-- | core/crypt.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/crypt.go b/core/crypt.go index 19a8420..067a0b3 100644 --- a/core/crypt.go +++ b/core/crypt.go @@ -8,6 +8,7 @@ import ( "strings" ) +// calculateStringHash calculates the sha1 checksum of a given string a. func calculateStringHash(a string) (string, error) { hash := sha1.New() hash.Write([]byte(a)) @@ -15,9 +16,10 @@ func calculateStringHash(a string) (string, error) { return strings.TrimSpace(fmt.Sprintf("%x", hashInBytes)), nil } -func CalculateBlockHash(block []byte) (string, error) { +// CalculateBlockHash calculates the sha1 checksum of a given byte slice b. +func CalculateBlockHash(b []byte) (string, error) { hash := sha1.New() - if _, err := io.Copy(hash, bytes.NewReader(block)); err != nil { + if _, err := io.Copy(hash, bytes.NewReader(b)); err != nil { return "", err } hashInBytes := hash.Sum(nil)[:20] |