md5哈希算法如何将数据压缩为固定长度?

发布于 2024-12-01 10:44:41 字数 301 浏览 6 评论 0原文

我知道 MD5 会生成 128 位摘要。我的问题是,它如何从 128bits+ 的消息中产生这个固定长度的输出?

编辑:

我现在对哈希函数有了更深入的了解。阅读这篇文章后,我意识到哈希函数是单向的,这意味着您无法将哈希值转换回纯文本。我的错误印象是,由于所有在线服务都可以将它们转换回字符串,但我意识到这只是彩虹表(映射到预先计算的哈希值的字符串集合)。

I know that MD5 produces a 128-bit digest. My question is, how does it produce this fixed length output from a message of 128bits+?

EDIT:

I have now a greater understanding of hashing functions now. After reading this article I have realized that hash functions are one-way, meaning that you can't convert the hash back to plaintext. I was under the misimpression that you could due to all the online services converting them back to strings, but I have realised that thats just rainbow tables (collections of string's mapped to pre-computed hashes).

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

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

发布评论

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

评论(4

浅听莫相离 2024-12-08 10:44:41

当您生成 MD5 哈希时,您并没有压缩输入数据。压缩意味着您可以将其解压缩回原始状态。另一方面,MD5 是一个单向过程。这就是为什么它被用于密码存储;理想情况下,您必须知道原始输入字符串才能再次生成相同的 MD5 结果。

此页面提供了 MD5 和类似哈希函数及其使用方式的精美图形说明:加密哈希图解指南

When you generate an MD5 hash, you're not compressing the input data. Compression implies that you'll be able to uncompress it back to it's original state. MD5, on the other hand, is a one-way process. This is why it's used for password storage; you ideally have to know the original input string to be able to generate the same MD5 result again.

This page provides a nice graphic-equipped explanation of MD5 and similar hash functions, and how they're used: An Illustrated Guide to Cryptographic Hashes

离不开的别离 2024-12-08 10:44:41

考虑从 128 位值开始,一次获取 128 位输入,然后将每个输入块与现有值进行异或。

MD5 比这复杂得多,但总体思路是相同的:一次处理 128 位输入。每个输入块可以改变结果的值,但对长度没有影响。

Consider something like starting with a 128-bit value, and taking input 128 bits at a time, and XORing each of those input blocks with the existing value.

MD5 is considerably more complex than that, but the general idea is the same: input is processed 128 bits at a time. Each input block can change the value of the result, but has no effect on the length.

执妄 2024-12-08 10:44:41

它与压缩无关(或者更好的是,很少)。有一个算法,它为每个初始状态和字节生成一个新状态。这种状态对于这种输入组合或多或少是唯一的。

It has noting (or, better, few) to do with compression. There is an algorithm which produces for every initial state and byte a new state. This state is more or less unique to this combination of inputs.

佼人 2024-12-08 10:44:41

简而言之,它会拆分成很多部分并进行操作。

如果您对冲突感到好奇,请考虑您的消息是只读的。

位空间比可读字符空间大得多。

In short, it will split into many parts and do operation.

If you are wonder about the collsion, consider your message is only Readable.

The bit space is much bigger than readable char space.

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