1 Star 0 Fork 0

青侠oO/FluentFTP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GetHash.vb 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
Imports System
Imports System.Net
Imports System.Threading
Imports System.Threading.Tasks
Imports FluentFTP
Namespace Examples
Friend Module GetHashExample
'-----------------------------------------------------------------------------------------
' NOTE! GetChecksum automatically uses the first available hash algorithm on the server,
' And it should be used as far as possible instead of GetHash, GetMD5, GetSHA256...
'-----------------------------------------------------------------------------------------
Sub GetHash()
Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
conn.Connect()
If conn.HashAlgorithms <> FtpHashAlgorithm.NONE Then
Dim hash As FtpHash
hash = conn.GetHash("/path/to/remote/somefile.ext")
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
If conn.HashAlgorithms.HasFlag(FtpHashAlgorithm.MD5) Then
conn.SetHashAlgorithm(FtpHashAlgorithm.MD5)
hash = conn.GetHash("/path/to/remote/somefile.ext")
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
End If
End If
End Using
End Sub
Async Function GetHashAsync() As Task
Dim token = New CancellationToken()
Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
Await conn.ConnectAsync(token)
If conn.HashAlgorithms <> FtpHashAlgorithm.NONE Then
Dim hash As FtpHash
hash = Await conn.GetHashAsync("/path/to/remote/somefile.ext", token)
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
If conn.HashAlgorithms.HasFlag(FtpHashAlgorithm.MD5) Then
conn.SetHashAlgorithm(FtpHashAlgorithm.MD5)
hash = Await conn.GetHashAsync("/path/to/remote/somefile.ext", token)
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
End If
End If
End Using
End Function
End Module
End Namespace
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/MuNet/FluentFTP.git
git@gitee.com:MuNet/FluentFTP.git
MuNet
FluentFTP
FluentFTP
master

搜索帮助