7
7
"archive/zip"
8
8
"bufio"
9
9
"bytes"
10
- "crypto/sha1"
11
10
"encoding/hex"
12
11
"errors"
13
12
"flag"
@@ -23,6 +22,7 @@ import (
23
22
"time"
24
23
25
24
"github.com/PuerkitoBio/goquery"
25
+ "golang.org/x/crypto/sha3"
26
26
)
27
27
28
28
var (
@@ -102,7 +102,7 @@ func download(prefix string) (content, hash []byte, err error) {
102
102
if found {
103
103
s .Find ("td" ).Each (func (_ int , s * goquery.Selection ) {
104
104
text := s .Text ()
105
- split := strings .Split (text , "(sha1 : " )
105
+ split := strings .Split (text , "(sha3 : " )
106
106
if len (split ) < 2 {
107
107
return
108
108
}
@@ -114,8 +114,8 @@ func download(prefix string) (content, hash []byte, err error) {
114
114
})
115
115
116
116
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 )
119
119
}
120
120
121
121
if url == "" {
@@ -129,7 +129,7 @@ func download(prefix string) (content, hash []byte, err error) {
129
129
}
130
130
131
131
// Ready Body Content
132
- shasum := sha1 . New ()
132
+ shasum := sha3 . New256 ()
133
133
content , err = ioutil .ReadAll (io .TeeReader (resp .Body , shasum ))
134
134
defer resp .Body .Close ()
135
135
if err != nil {
0 commit comments