MD5 输入/输出的最大长度
可以进行 md5 哈希处理的字符串的最大长度是多少?或者:如果没有限制,如果有,md5 输出值的最大长度是多少?
What is the maximum length of the string that can have md5 hashed? Or: If it has no limit, and if so what will be the max length of the md5 output value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
MD5 将任意长度的消息处理为 128 位的固定长度输出,通常表示为 32 个十六进制数字的序列。
MD5 processes an arbitrary-length message into a fixed-length output of 128 bits, typically represented as a sequence of 32 hexadecimal digits.
请参阅此处了解更多信息。
See more here.
您可以具有任意长度,但当然,如果字符串输入太长,计算机上可能会出现内存问题。输出始终为 32 个字符。
You can have any length, but of course, there can be a memory issue on the computer if the String input is too long. The output is always 32 characters.
该算法被设计为支持任意输入长度。也就是说,您可以计算大文件的哈希值,例如 DVD 的 ISO...
如果输入有限制,则它可能来自使用哈希函数的环境。假设您要计算一个文件,并且环境有 MAX_FILE 限制。
但输出字符串始终相同:32 个十六进制字符(128 位)!
The algorithm has been designed to support arbitrary input length. I.e you can compute hashes of big files like ISO of a DVD...
If there is a limitation for the input it could come from the environment where the hash function is used. Let's say you want to compute a file and the environment has a MAX_FILE limit.
But the output string will be always the same: 32 hex chars (128 bits)!
128 位 MD5 哈希值表示为 32 个十六进制数字的序列。
A 128-bit MD5 hash is represented as a sequence of 32 hexadecimal digits.
您可能需要使用 SHA-1 而不是 MD5,因为 MD5 被认为已损坏。
您可以在这篇维基百科文章中了解有关 MD5 漏洞的更多信息。
You may want to use SHA-1 instead of MD5, as MD5 is considered broken.
You can read more about MD5 vulnerabilities in this Wikipedia article.
据我所知md5的输入没有限制。一些实现要求在将整个输入传递到 md5 函数之前将其加载到内存中(即,该实现作用于内存块,而不是流),但这不是算法本身的限制。输出始终为 128 位。请注意,md5 不是加密算法,而是加密哈希。这意味着您可以使用它来验证数据块的完整性,但无法反转哈希。
另请注意,md5 被认为已损坏,因此您不应将其用于任何与安全相关的内容(验证下载文件的完整性等仍然可以)。
There is no limit to the input of md5 that I know of. Some implementations require the entire input to be loaded into memory before passing it into the md5 function (i.e., the implementation acts on a block of memory, not on a stream), but this is not a limitation of the algorithm itself. The output is always 128 bits. Note that md5 is not an encryption algorithm, but a cryptographic hash. This means that you can use it to verify the integrity of a chunk of data, but you cannot reverse the hashing.
Also note that md5 is considered broken, so you shouldn't use it for anything security-related (it's still fine to verify the integrity of downloaded files and such).
md5 算法将消息长度附加到最后一个块的最后 64 位,因此可以公平地说消息可以是 2^64 位长(18 e18 位)。
md5 algorithm appends the message length to the last 64 bits of the last block, thus it would be fair to say that the message can be 2^64 bits long (18 e18 bits).
MD5 输入的最大长度:最大可定义和可用的比特流
位定义约束流可能取决于操作系统、硬件约束、编程语言等...
MD5 输出的长度:固定长度始终为 128 位
为了方便显示,通常以十六进制显示,因为每个十六进制数字(0-1-2-3-4-5-6-7-8-9-ABCDEF)占用4位空间,所以其输出可以显示为 32 个十六进制数字。
128 位 = 16 字节 = 32 个十六进制数字
Max length for MD5 input : largest definable and usable stream of bit
A stream of bit definition constraints can depend on operating system, hardware constraints, programming language and more...
Length for MD5 output : Fixed-length always 128 bits
For easier display, they are usually displayed in hex, which because each hex digit (0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F) takes up 4 bits of space, so its output can be displayed as 32 hex digits.
128 bits = 16 bytes = 32 hex digits