use more official blake2b checksum
This commit is contained in:
parent
1dcebc4eca
commit
62aea5413e
@ -2,6 +2,7 @@ package sync
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -11,7 +12,7 @@ import (
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
||||
"github.com/dchest/blake2b"
|
||||
_ "golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
func SyncExerciceHints(i Importer, exercice fic.Exercice) (errs []string) {
|
||||
@ -52,7 +53,7 @@ func SyncExerciceHints(i Importer, exercice fic.Exercice) (errs []string) {
|
||||
// Handle big files as downloadable content
|
||||
if res, err := i.importFile(path.Join(exercice.Path, "hints", hfile), func(filePath string, origin string) (interface{}, error) {
|
||||
// Calculate hash
|
||||
hash512 := blake2b.New512()
|
||||
hash512 := crypto.BLAKE2b_512.New()
|
||||
if fd, err := os.Open(filePath); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
||||
"github.com/dchest/blake2b"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
type Importer interface {
|
||||
|
@ -2,7 +2,8 @@ package fic
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/sha1"
|
||||
"crypto"
|
||||
_ "crypto/sha1"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
@ -10,7 +11,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/dchest/blake2b"
|
||||
_ "golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
var FilesDir string = "./FILES/"
|
||||
@ -110,8 +111,8 @@ func checkFileHash(filePath string, digest []byte) ([]byte, int64, error) {
|
||||
defer fd.Close()
|
||||
|
||||
reader := bufio.NewReader(fd)
|
||||
hash160 := sha1.New()
|
||||
hash512 := blake2b.New512()
|
||||
hash160 := crypto.SHA1.New()
|
||||
hash512 := crypto.BLAKE2b_512.New()
|
||||
|
||||
w := io.MultiWriter(hash160, hash512)
|
||||
if _, err := io.Copy(w, reader); err != nil {
|
||||
|
@ -3,7 +3,7 @@ package fic
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/dchest/blake2b"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
type Key struct {
|
||||
@ -37,7 +37,7 @@ func (e Exercice) GetKeys() ([]Key, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func getHashedKey(raw_value string) [blake2b.KeySize]byte {
|
||||
func getHashedKey(raw_value string) [blake2b.Size]byte {
|
||||
hash := blake2b.Sum512([]byte(raw_value))
|
||||
return hash
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user