mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 05:11:06 +02:00
update: imohash samples more of the file
This commit is contained in:
parent
50e0f625bc
commit
5cf4d7c103
2 changed files with 5 additions and 4 deletions
|
@ -186,15 +186,16 @@ func MD5HashFile(fname string, doShowProgress bool) (hash256 []byte, err error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var imofull = imohash.NewCustom(0, 0)
|
||||||
|
var imopartial = imohash.NewCustom(16*16*8*1024, 128*1024)
|
||||||
|
|
||||||
// IMOHashFile returns imohash
|
// IMOHashFile returns imohash
|
||||||
func IMOHashFile(fname string) (hash []byte, err error) {
|
func IMOHashFile(fname string) (hash []byte, err error) {
|
||||||
b, err := imohash.SumFile(fname)
|
b, err := imopartial.SumFile(fname)
|
||||||
hash = b[:]
|
hash = b[:]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var imofull = imohash.NewCustom(0, 0)
|
|
||||||
|
|
||||||
// IMOHashFileFull returns imohash of full file
|
// IMOHashFileFull returns imohash of full file
|
||||||
func IMOHashFileFull(fname string) (hash []byte, err error) {
|
func IMOHashFileFull(fname string) (hash []byte, err error) {
|
||||||
b, err := imofull.SumFile(fname)
|
b, err := imofull.SumFile(fname)
|
||||||
|
|
|
@ -108,7 +108,7 @@ func TestIMOHashFile(t *testing.T) {
|
||||||
defer os.Remove("bigfile.test")
|
defer os.Remove("bigfile.test")
|
||||||
b, err := IMOHashFile("bigfile.test")
|
b, err := IMOHashFile("bigfile.test")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "c0d1e123ca94148ffea146137684ebb9", fmt.Sprintf("%x", b))
|
assert.Equal(t, "c0d1e12301e6c635f6d4a8ea5c897437", fmt.Sprintf("%x", b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestXXHashFile(t *testing.T) {
|
func TestXXHashFile(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue