feat: implement cross-protocol checksum verification for file transfers

This commit is contained in:
2026-06-09 14:38:46 +01:00
parent 715c4eccb6
commit 93ad8c9321
13 changed files with 171 additions and 14 deletions
+15
View File
@@ -1,6 +1,8 @@
package smb
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"net"
@@ -243,3 +245,16 @@ func (e *SMBExplorer) WriteFile(path string, r io.Reader, size int64) error {
_, err = io.Copy(f, r)
return err
}
func (e *SMBExplorer) Checksum(path string) (string, error) {
r, err := e.ReadFile(path)
if err != nil {
return "", err
}
defer r.Close()
h := md5.New()
if _, err := io.Copy(h, r); err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)), nil
}