diff --git a/web/fup/hashfs/hashfs.go b/web/fup/hashfs/hashfs.go index 2eafa5d126..362275b7f2 100644 --- a/web/fup/hashfs/hashfs.go +++ b/web/fup/hashfs/hashfs.go @@ -105,7 +105,8 @@ func (s *FS) build() error { if err != nil { return fmt.Errorf("reading %q: %w", fpath, err) } - hexDigest := hex.EncodeToString(sha512.New().Sum(bs)[:6]) + fileHash := sha512.Sum512(bs) + hexDigest := hex.EncodeToString(fileHash[:6]) // and fix it up in the filename. oldName := fpath diff --git a/web/fup/hashfs/hashfs_test.go b/web/fup/hashfs/hashfs_test.go index 7374824627..8ae5d084ce 100644 --- a/web/fup/hashfs/hashfs_test.go +++ b/web/fup/hashfs/hashfs_test.go @@ -26,8 +26,8 @@ func TestHashingFS(t *testing.T) { newName string wantContent string }{ - {"foo", "foo.68656c6c6f2c", "hello, world"}, - {"bar/bar.txt", "bar/bar.666f6f206261.txt", "foo bar baz"}, + {"foo", "foo.8710339dcb68", "hello, world"}, + {"bar/bar.txt", "bar/bar.bce50343a56f.txt", "foo bar baz"}, } for _, tc := range tcs {