From e6c12b02674a04ca34e27b46f6ca3261fca3c677 Mon Sep 17 00:00:00 2001 From: axtloss Date: Sun, 18 Feb 2024 01:19:58 +0100 Subject: Add comments and function descriptions --- core/crypt.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/crypt.go') 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] -- cgit v1.2.3