文件上次修改时间
在检测文件是否已更改时,使用“文件上次修改时间”(例如 NTFS)是否安全?如果不是,文件备份应用程序是否总是散列整个文件以检查更改?如果是这样,什么哈希算法适合此检查?
Is it safe to use File Last Modified (e.g. NTFS) when detecting if a file has changed? If not, does file backup applications always hash the whole file to check for changes? If so what hash algorithm is suited for this check?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于应用程序的要求。它能容忍误报吗?假阴性?
文件上次修改日期不可靠。例如,FTP 可以更改修改日期而不更改文件,或者文件可以下载两次,一次下载一次,更改修改日期而不更改文件。另一方面,有一些实用程序可以更改文件但保留相同的文件上次修改日期。
如果在文件发生更改时绝对必须对其采取操作,则可靠的方法是使用良好的哈希值或指纹。这确实需要时间。在不花费太多时间的情况下提高几率的一种方法是将修改日期与文件大小进行比较,但这也不是万无一失的。
It depends on the requirements of the application. Can it tolerate false positives? False negatives?
A File Last Modified date is not reliable. For example, FTP may change the modified date without changing the file, or a file could be downloaded twice, once over itself, changing the modified date without changing the file. On the other hand, there are a few utilities that will change a file but keep the same File Last Modified date.
If action absolutely must be taken on a file when it has been changed, the reliable way is to use a good hash or fingerprint. This does take time. One way to improve the odds without taking so much time would be to compare the modified date along with the file size, but again this is not foolproof.
我不太相信上次修改时间,因为即使打开文件并添加单个字符也会改变它的修改时间。散列存在冲突问题,所以我建议阅读 Rabin 的指纹算法。
I wouldn't trust last modified time so much since even opening a file and adding a single character would change it modification time. Hashing has the problem of collisions, so I would suggest reading about Rabin's Fingerprinting algorithm.
我认为要习惯设置有效且定期监控的哈希检查。我认为上次修改并不像许多人想象的那么安全。坚持检查哈希值并使用定期检查哈希值的好软件。
相信我,一旦您习惯了不选择最简单的路线并始终选择最安全的路线,您就会养成良好的习惯,从而推动您采取其他安全措施。
I think get used to setting up effective and routinely monitored hash check. Last modified I think is not as safe as many like to think. Stick with checking the hash and use a good software that does it regularly.
Trust me, once you get used to not picking easiest route and always do safest, you’ll develop great habits that will carry you forward to other security measures.