{"id":1607,"date":"2010-11-16T19:30:02","date_gmt":"2010-11-16T17:30:02","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1607"},"modified":"2012-06-03T15:43:25","modified_gmt":"2012-06-03T13:43:25","slug":"verify-file-hash-after-ftp-upload","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/verify-file-hash-after-ftp-upload","title":{"rendered":"Verify file hash after FTP upload"},"content":{"rendered":"<p>This blog post describes hot to check the file checksum (hash) after upload to FTP server. Ftp.dll <a href=\"\/ftp\">.NET FTP component<\/a> supports most popular hashing algorithms like 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 upload the file, ask the server for hash of the uploaded file, 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.Upload(&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.Upload(&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 hot to check the file checksum (hash) after upload to FTP server. Ftp.dll .NET FTP component supports most popular hashing algorithms like 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 upload the file, ask the 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,24,57],"class_list":["post-1607","post","type-post","status-publish","format-standard","hentry","category-ftp-dll","tag-c","tag-ftp","tag-ftp-component","tag-ftps","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1607"}],"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=1607"}],"version-history":[{"count":6,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1607\/revisions"}],"predecessor-version":[{"id":3091,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1607\/revisions\/3091"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}