diff options
author | axtloss <axtlos@getcryst.al> | 2024-02-18 01:19:58 +0100 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-02-18 01:19:58 +0100 |
commit | e6c12b02674a04ca34e27b46f6ca3261fca3c677 (patch) | |
tree | 0d5d785428436bf3fcc751eb8e2be4ca0b3bfe04 /core/crypt.go | |
parent | 6a3db4c72485aba6187466005473e287f539e3ce (diff) | |
download | fsverify-e6c12b02674a04ca34e27b46f6ca3261fca3c677.tar.gz fsverify-e6c12b02674a04ca34e27b46f6ca3261fca3c677.tar.bz2 |
Add comments and function descriptions
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] |