{"id":1600,"date":"2010-11-16T12:55:45","date_gmt":"2010-11-16T10:55:45","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1600"},"modified":"2012-06-03T15:41:16","modified_gmt":"2012-06-03T13:41:16","slug":"verify-file-hash-after-ftp-download","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/verify-file-hash-after-ftp-download","title":{"rendered":"Verify file hash after FTP download"},"content":{"rendered":"<p>This blog post describes how to check the file checksum (hash) after downloading the file from FTP server. Ftp.dll <a href=\"\/ftp\">.NET FTP component<\/a> supports most popular hashing algorithms (CRC, MD5 and SHA1).<\/p>\n<p>First add appropriate namespaces:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version\r\n\r\nusing Limilabs.FTP.Client;\r\nusing Limilabs.FTP.Client.Hash;\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version\r\n\r\nImports Limilabs.FTP.Client\r\nImports Limilabs.FTP.Client.Hash\r\n\r\n<\/pre>\n<p>Then download the file, ask server for its hash, compute the local hash and compare them:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version\r\n\r\nusing (Ftp client = new Ftp())\r\n{\r\n    client.Connect(&quot;ftp.example.org&quot;);\r\n    client.Login(&quot;user&quot;, &quot;password&quot;);\r\n\r\n    client.Download(&quot;report.txt&quot;, @&quot;c:\\report.txt&quot;);\r\n\r\n    byte&#x5B;] serverHash = client.GetFileHash(\r\n        &quot;report.txt&quot;,\r\n        FtpHashType.CRC);\r\n\r\n    FileHash hash = new FileHash(FtpHashType.CRC);\r\n    bool hashIsValid = hash.IsValid(@&quot;c:\\report.txt&quot;, serverHash);\r\n\r\n    Console.WriteLine(hashIsValid);\r\n\r\n    client.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version\r\n\r\nUsing client As New Ftp()\r\n\tclient.Connect(&quot;ftp.example.org&quot;)\r\n\tclient.Login(&quot;user&quot;, &quot;password&quot;)\r\n\r\n\tclient.Download(&quot;report.txt&quot;, &quot;c:\\report.txt&quot;)\r\n\r\n\tDim serverHash As Byte() = client.GetFileHash( _\r\n\t\t&quot;report.txt&quot;, _\r\n\t\tFtpHashType.CRC)\r\n\r\n\tDim hash As New FileHash(FtpHashType.CRC)\r\n\tDim hashIsValid As Boolean = hash.IsValid(&quot;c:\\report.txt&quot;, serverHash)\r\n\r\n\tConsole.WriteLine(hashIsValid)\r\n\r\n\tclient.Close()\r\nEnd Using\r\n<\/pre>\n<p>You can use <strong>CRC<\/strong>, <strong>MD5 <\/strong>and <strong>SHA1 <\/strong>algorithms for hash verification.<\/p>\n<p>You can <a href=\"\/ftp\">download Ftp.dll FTP\/FTPS client for .NET here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post describes how to check the file checksum (hash) after downloading the file from FTP server. Ftp.dll .NET FTP component supports most popular hashing algorithms (CRC, MD5 and SHA1). First add appropriate namespaces: \/\/ C# version using Limilabs.FTP.Client; using Limilabs.FTP.Client.Hash; &#8216; VB.NET version Imports Limilabs.FTP.Client Imports Limilabs.FTP.Client.Hash Then download the file, ask server [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[15,22,80,57],"class_list":["post-1600","post","type-post","status-publish","format-standard","hentry","category-ftp-dll","tag-c","tag-ftp","tag-ftp-component","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1600"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=1600"}],"version-history":[{"count":6,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1600\/revisions"}],"predecessor-version":[{"id":3089,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1600\/revisions\/3089"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}