Skip to content

Commit b2839fc

Browse files
committed
sqlite.org now publishing sha3
1 parent 0382f53 commit b2839fc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

upgrade/upgrade.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"archive/zip"
88
"bufio"
99
"bytes"
10-
"crypto/sha1"
1110
"encoding/hex"
1211
"errors"
1312
"flag"
@@ -23,6 +22,7 @@ import (
2322
"time"
2423

2524
"github.com/PuerkitoBio/goquery"
25+
"golang.org/x/crypto/sha3"
2626
)
2727

2828
var (
@@ -102,7 +102,7 @@ func download(prefix string) (content, hash []byte, err error) {
102102
if found {
103103
s.Find("td").Each(func(_ int, s *goquery.Selection) {
104104
text := s.Text()
105-
split := strings.Split(text, "(sha1: ")
105+
split := strings.Split(text, "(sha3: ")
106106
if len(split) < 2 {
107107
return
108108
}
@@ -114,8 +114,8 @@ func download(prefix string) (content, hash []byte, err error) {
114114
})
115115

116116
targetHash, err := hex.DecodeString(hashString)
117-
if err != nil || len(targetHash) != sha1.Size {
118-
return nil, nil, fmt.Errorf("unable to find valid sha1 hash on sqlite.org: %q", hashString)
117+
if err != nil || len(targetHash) != 32 {
118+
return nil, nil, fmt.Errorf("unable to find valid sha3-256 hash on sqlite.org: %q", hashString)
119119
}
120120

121121
if url == "" {
@@ -129,7 +129,7 @@ func download(prefix string) (content, hash []byte, err error) {
129129
}
130130

131131
// Ready Body Content
132-
shasum := sha1.New()
132+
shasum := sha3.New256()
133133
content, err = ioutil.ReadAll(io.TeeReader(resp.Body, shasum))
134134
defer resp.Body.Close()
135135
if err != nil {

0 commit comments

Comments
 (0)