检查一个文件是否与其他文件相同
好吧,我的服务器上有一个文件,我的计算机上有另一个文件。我想做的是一个简单的更新程序,检查我的计算机的文件是否等于服务器上上传的文件。 (如果相等则尚未更新,如果不相等则下载)
我正在使用 QNetworkAccessManager 下载文件。有什么想法吗?
Well i have one file on my server and other on my computer. What i want to do is a simple updater that checks if the file of my computer is equal to the one uploaded in the server. (If it's equal then it hasn't been updated, if it's not equal then download)
I'm using QNetworkAccessManager to download files. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过以下方式从文件生成校验和:
对两个文件执行此操作(同时以某种方式从一台计算机到另一台计算机获取签名)并比较结果。
You can generate a checksum from a file in the following way:
Do this for both files (while somehow getting the signature from one machine to the other) and compare the results.
您可以计算文件的 SHA-1 校验和,然后比较两个校验和。如果它们相等,则文件具有相同的内容。
You could calculate the SHA-1 checksum of the file and then compare the two checksums. If they are equal, the files have the same contents.
您的服务器上需要有一些东西(WebService 或普通的 servlet/php),它将文件名(或 ID 或 smth)作为参数并用其校验和(SHA1、MD5)进行回复。
如果您的本地文件校验和与远程文件校验和不同 - 请下载它。
You will need something on your server (a WebService, or a plain servlet/php) that would take a file name (or ID or smth) as parameter and reply with its checksum (SHA1, MD5).
If your local file checksum differs from the remote one - download it.