1

I'm using renci.sshnet library for upload a file on an SFTP server.

How can I calculate a hash of an uploaded file and compare with my local file? Is doable with this library?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
abellos
  • 13
  • 2

1 Answers1

0

Start here: How to perform checksums during a SFTP file transfer for data integrity?.

It explains that calculation checksum for SFTP upload is hardly doable and probably not even useful.


If you want to do it anyway, in most cases you would have to resort to executing a shell command like sha256sum:

Dim Command = client.RunCommand("sha256sum /remote/path/test.txt")
If Command.ExitStatus <> 0 Then
    Throw New Exception(Command.Error)
End If
Dim tokens = Command.Result.Split(" ")
Dim checksum = Tokens(0)
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992