feature: hasher using hex strings now
parent
ac8c18e754
commit
e6ee7860b3
|
@ -3,6 +3,7 @@ package hasher
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -38,7 +39,7 @@ func (self *Hasher) GetFileHashString(fileLocation string) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(bytes), nil
|
return convertBytesToString(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Hasher) GetFileHashBytes(fileLocation string) ([]byte, error) {
|
func (self *Hasher) GetFileHashBytes(fileLocation string) ([]byte, error) {
|
||||||
|
@ -57,7 +58,7 @@ func (self *Hasher) GetHashString(reader io.Reader) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(bytes), nil
|
return convertBytesToString(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Hasher) GetHashBytes(reader io.Reader) ([]byte, error) {
|
func (self *Hasher) GetHashBytes(reader io.Reader) ([]byte, error) {
|
||||||
|
@ -70,3 +71,7 @@ func (self *Hasher) GetHashBytes(reader io.Reader) ([]byte, error) {
|
||||||
|
|
||||||
return hasher.Sum(nil), nil
|
return hasher.Sum(nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertBytesToString(bytes []byte) string {
|
||||||
|
return hex.EncodeToString(bytes)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue