use more official blake2b checksum

This commit is contained in:
nemunaire 2018-02-03 02:03:08 +01:00
commit 62aea5413e
4 changed files with 11 additions and 9 deletions

View file

@ -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 {

View file

@ -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
}