Skip to content

Commit

Permalink
Make use of HashFromBytes everywhere
Browse files Browse the repository at this point in the history
It feels a bit silly to have a function and to not make use of it.
  • Loading branch information
jvoisin authored and fguillot committed Mar 11, 2024
1 parent 74e4032 commit 9c8a7df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions internal/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (

// HashFromBytes returns a SHA-256 checksum of the input.
func HashFromBytes(value []byte) string {
sum := sha256.Sum256(value)
return fmt.Sprintf("%x", sum)
return fmt.Sprintf("%x", sha256.Sum256(value))
}

// Hash returns a SHA-256 checksum of a string.
Expand Down
9 changes: 5 additions & 4 deletions internal/ui/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ package static // import "miniflux.app/v2/internal/ui/static"

import (
"bytes"
"crypto/sha256"
"embed"
"fmt"

"miniflux.app/v2/internal/crypto"

"github.com/tdewolff/minify/v2"
"github.com/tdewolff/minify/v2/css"
"github.com/tdewolff/minify/v2/js"
Expand Down Expand Up @@ -48,7 +49,7 @@ func CalculateBinaryFileChecksums() error {
return err
}

binaryFileChecksums[dirEntry.Name()] = fmt.Sprintf("%x", sha256.Sum256(data))
binaryFileChecksums[dirEntry.Name()] = crypto.HashFromBytes(data)
}

return nil
Expand Down Expand Up @@ -102,7 +103,7 @@ func GenerateStylesheetsBundles() error {
}

StylesheetBundles[bundle] = minifiedData
StylesheetBundleChecksums[bundle] = fmt.Sprintf("%x", sha256.Sum256(minifiedData))
StylesheetBundleChecksums[bundle] = crypto.HashFromBytes(minifiedData)
}

return nil
Expand Down Expand Up @@ -166,7 +167,7 @@ func GenerateJavascriptBundles() error {
}

JavascriptBundles[bundle] = minifiedData
JavascriptBundleChecksums[bundle] = fmt.Sprintf("%x", sha256.Sum256(minifiedData))
JavascriptBundleChecksums[bundle] = crypto.HashFromBytes(minifiedData)
}

return nil
Expand Down

0 comments on commit 9c8a7df

Please sign in to comment.