mirror of https://github.com/mattn/go-sqlite3.git
sqlite.org now publishing sha3
This commit is contained in:
parent
4c62eaf7e5
commit
6188a7577e
|
@ -7,7 +7,6 @@ import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
@ -23,6 +22,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -110,7 +110,7 @@ func download(prefix string) (content, hash []byte, err error) {
|
||||||
if found {
|
if found {
|
||||||
s.Find("td").Each(func(_ int, s *goquery.Selection) {
|
s.Find("td").Each(func(_ int, s *goquery.Selection) {
|
||||||
text := s.Text()
|
text := s.Text()
|
||||||
split := strings.Split(text, "(sha1: ")
|
split := strings.Split(text, "(sha3: ")
|
||||||
if len(split) < 2 {
|
if len(split) < 2 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ func download(prefix string) (content, hash []byte, err error) {
|
||||||
})
|
})
|
||||||
|
|
||||||
targetHash, err := hex.DecodeString(hashString)
|
targetHash, err := hex.DecodeString(hashString)
|
||||||
if err != nil || len(targetHash) != sha1.Size {
|
if err != nil || len(targetHash) != 32 {
|
||||||
return nil, nil, fmt.Errorf("unable to find valid sha1 hash on sqlite.org: %q", hashString)
|
return nil, nil, fmt.Errorf("unable to find valid sha3-256 hash on sqlite.org: %q", hashString)
|
||||||
}
|
}
|
||||||
|
|
||||||
if url == "" {
|
if url == "" {
|
||||||
|
@ -137,7 +137,7 @@ func download(prefix string) (content, hash []byte, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ready Body Content
|
// Ready Body Content
|
||||||
shasum := sha1.New()
|
shasum := sha3.New256()
|
||||||
content, err = ioutil.ReadAll(io.TeeReader(resp.Body, shasum))
|
content, err = ioutil.ReadAll(io.TeeReader(resp.Body, shasum))
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue