diff --git a/src/croc/croc.go b/src/croc/croc.go index 1c41c6d6..10ea2b83 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -224,6 +224,9 @@ func (c *Client) sendCollectFiles(options TransferOptions) (err error) { } log.Debugf("%+v", c.FilesToTransfer[i]) } + if c.Options.HashAlgorithm == "" { + c.Options.HashAlgorithm = "xxhash" + } c.FilesToTransfer[i].Hash, err = utils.HashFile(fullPath, c.Options.HashAlgorithm) log.Debugf("hashed %s to %x using %s", fullPath, c.FilesToTransfer[i].Hash, c.Options.HashAlgorithm) totalFilesSize += fstats.Size() diff --git a/src/utils/utils_test.go b/src/utils/utils_test.go index 28471488..a94fd7cc 100644 --- a/src/utils/utils_test.go +++ b/src/utils/utils_test.go @@ -175,9 +175,9 @@ func TestHashFile(t *testing.T) { if err := tmpfile.Close(); err != nil { panic(err) } - hashed, err := HashFile(tmpfile.Name()) + hashed, err := HashFile(tmpfile.Name(), "xxhash") assert.Nil(t, err) - assert.Equal(t, "18c9673a4bb8325d323e7f24fda9ae1e", fmt.Sprintf("%x", hashed)) + assert.Equal(t, "e66c561610ad51e2", fmt.Sprintf("%x", hashed)) } func TestPublicIP(t *testing.T) {