将本地元数据可靠地关联到远程文件?

发布于 2024-07-29 21:40:53 字数 337 浏览 1 评论 0原文

WinForms / C#

我的应用程序允许用户指定 1) 2) 给定文件的附加信息,这两个信息都会上传到服务器。 有两个独立的上传:首先是文件,然后(也许更)是元数据。

请假设该文件始终保持不变且可用(对于代码)。

上传元数据时,我需要确保它与其给定文件关联,而无需再次上传该文件(它们是大文件)。

我的计划是使用文件以下三个属性的 MD5 哈希值:

  • 内容
  • 大小
  • 创建日期

该哈希值将伴随文件和元数据各自的上传(以及最终的持久性)。

我忽略了哪些更明智的解决方案?

WinForms / C#

My application allows the user to specify 1) additional information for 2) a given file, both of which are uploaded to the server. There are two isolated uploads: first the file, and (maybe much) later the metadata.

Please assume the file to be always unchanged and available (to the code).

When the metadata is uploaded, I need to ensure it is associated with its given file without again uploading that file (they're big files).

My plan is to use an MD5 hash of the following three attributes of the file:

  • contents
  • size
  • created date

The hash will accompany both the file and the metadata in their respective uploads (and eventual persistence).

What smarter solution am I overlooking?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

跨年 2024-08-05 21:40:56

您可以考虑使用 SHA-1 甚至更好的 SHA-256 来代替 MD5,因为 MD5 哈希值可能不够唯一:可以生成大小和 MD5 哈希值与其他文件匹配的文件。 例如,请参阅 MD5 漏洞

更新:如果文件唯一性并不严格重要,您可能会发现在上传过程中生成自动递增的 id 更方便。

You may consider using SHA-1 or even better SHA-256 instead of MD5, since MD5 hashes may not be unique enough: it is possible to generate a file with size and MD5 hash matching those of other file. See, for example, MD5 vulnerability.

Upd: if file uniqueness is not strictly important, you may find much more convenient to just generate an auto-incremented id during upload.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文