在VB.NET中使用Renci SSH.NET计算文件的哈希 [英] Calculate hash of file with Renci SSH.NET in VB.NET

查看:86
本文介绍了在VB.NET中使用Renci SSH.NET计算文件的哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用renci.sshnet库在SFTP服务器上上传文件.

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?

推荐答案

从此处开始:如何在SFTP文件传输期间执行校验和数据完整性?.

它解释了SFTP上传的计算校验和几乎不可行,甚至可能没有用.

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

如果仍然要执行此操作,则在大多数情况下,您将不得不执行诸如 sha256sum 这样的shell命令:

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)

这篇关于在VB.NET中使用Renci SSH.NET计算文件的哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆