Make use of HashFromBytes everywhere
It feels a bit silly to have a function and to not make use of it.
This commit is contained in:
parent
74e4032ffc
commit
9c8a7dfffe
2 changed files with 6 additions and 6 deletions
|
@ -17,8 +17,7 @@ import (
|
||||||
|
|
||||||
// HashFromBytes returns a SHA-256 checksum of the input.
|
// HashFromBytes returns a SHA-256 checksum of the input.
|
||||||
func HashFromBytes(value []byte) string {
|
func HashFromBytes(value []byte) string {
|
||||||
sum := sha256.Sum256(value)
|
return fmt.Sprintf("%x", sha256.Sum256(value))
|
||||||
return fmt.Sprintf("%x", sum)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash returns a SHA-256 checksum of a string.
|
// Hash returns a SHA-256 checksum of a string.
|
||||||
|
|
|
@ -5,10 +5,11 @@ package static // import "miniflux.app/v2/internal/ui/static"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"miniflux.app/v2/internal/crypto"
|
||||||
|
|
||||||
"github.com/tdewolff/minify/v2"
|
"github.com/tdewolff/minify/v2"
|
||||||
"github.com/tdewolff/minify/v2/css"
|
"github.com/tdewolff/minify/v2/css"
|
||||||
"github.com/tdewolff/minify/v2/js"
|
"github.com/tdewolff/minify/v2/js"
|
||||||
|
@ -48,7 +49,7 @@ func CalculateBinaryFileChecksums() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
binaryFileChecksums[dirEntry.Name()] = fmt.Sprintf("%x", sha256.Sum256(data))
|
binaryFileChecksums[dirEntry.Name()] = crypto.HashFromBytes(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -102,7 +103,7 @@ func GenerateStylesheetsBundles() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
StylesheetBundles[bundle] = minifiedData
|
StylesheetBundles[bundle] = minifiedData
|
||||||
StylesheetBundleChecksums[bundle] = fmt.Sprintf("%x", sha256.Sum256(minifiedData))
|
StylesheetBundleChecksums[bundle] = crypto.HashFromBytes(minifiedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -166,7 +167,7 @@ func GenerateJavascriptBundles() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
JavascriptBundles[bundle] = minifiedData
|
JavascriptBundles[bundle] = minifiedData
|
||||||
JavascriptBundleChecksums[bundle] = fmt.Sprintf("%x", sha256.Sum256(minifiedData))
|
JavascriptBundleChecksums[bundle] = crypto.HashFromBytes(minifiedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue