From 6188a7577ef277c69f6a25a4730b0fa8b53181e6 Mon Sep 17 00:00:00 2001 From: Diego Becciolini Date: Wed, 2 Sep 2020 22:52:19 +0100 Subject: [PATCH] sqlite.org now publishing sha3 --- upgrade/upgrade.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index 919e186..06255cb 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -7,7 +7,6 @@ import ( "archive/zip" "bufio" "bytes" - "crypto/sha1" "encoding/hex" "errors" "flag" @@ -23,6 +22,7 @@ import ( "time" "github.com/PuerkitoBio/goquery" + "golang.org/x/crypto/sha3" ) var ( @@ -110,7 +110,7 @@ func download(prefix string) (content, hash []byte, err error) { if found { s.Find("td").Each(func(_ int, s *goquery.Selection) { text := s.Text() - split := strings.Split(text, "(sha1: ") + split := strings.Split(text, "(sha3: ") if len(split) < 2 { return } @@ -122,8 +122,8 @@ func download(prefix string) (content, hash []byte, err error) { }) targetHash, err := hex.DecodeString(hashString) - if err != nil || len(targetHash) != sha1.Size { - return nil, nil, fmt.Errorf("unable to find valid sha1 hash on sqlite.org: %q", hashString) + if err != nil || len(targetHash) != 32 { + return nil, nil, fmt.Errorf("unable to find valid sha3-256 hash on sqlite.org: %q", hashString) } if url == "" { @@ -137,7 +137,7 @@ func download(prefix string) (content, hash []byte, err error) { } // Ready Body Content - shasum := sha1.New() + shasum := sha3.New256() content, err = ioutil.ReadAll(io.TeeReader(resp.Body, shasum)) defer resp.Body.Close() if err != nil {