有人告诉我,他见过这样的软件系统:

从其他系统检索MD5加密密码; 解密加密的密码和 使用系统自己的算法将密码存储在系统的数据库中。

这可能吗?我认为解密MD5哈希是不可能/可行的。

我知道有MD5字典,但是有真正的解密算法吗?


当前回答

解密(直接从散列值中获取纯文本,以一种算法方式),没有。

然而,有一些方法使用所谓的彩虹表。如果你的密码是没有盐的散列,这是非常可行的。

其他回答

从技术上讲,这是“可能的”,但在非常严格的条件下(彩虹表,基于用户密码在哈希数据库中的可能性非常小的暴力强制)。

但这并不意味着它是

可行的 或 安全

你不想“反转”一个MD5哈希。使用下面列出的方法,您将永远不需要。“逆转”MD5实际上被认为是恶意的——一些网站提供了“破解”和暴力破解MD5哈希的能力——但它们都是包含字典单词、以前提交的密码和其他单词的庞大数据库。有一个非常小的机会,它将有你需要反向的MD5哈希。如果你已经咸MD5哈希-这也不会工作!:)


使用MD5哈希的登录方式应该是: 在注册过程中: 用户创建密码->密码使用数据库存储的MD5 ->哈希值进行哈希

在登录: 用户输入用户名和密码->(用户名选中)密码使用MD5哈希->哈希与数据库中存储的哈希进行比较

当需要“丢失密码”时: 2个选择:

用户发送一个随机密码来登录,然后在第一次登录时修改它。

or

用户会被发送一个链接来更改他们的密码(如果你有安全问题/等等),然后新密码被散列,并用数据库中的旧密码替换

不,不可能反转诸如MD5这样的哈希函数:给定输出哈希值,除非已知关于输入消息的足够信息,否则不可能找到输入消息。

解密不是为哈希函数定义的函数;加密和解密是CBC模式下AES等密码的功能;哈希函数不加密也不解密。哈希函数用于摘要输入消息。顾名思义,没有反向算法可以设计。


MD5 has been designed as a cryptographically secure, one-way hash function. It is now easy to generate collisions for MD5 - even if a large part of the input message is pre-determined. So MD5 is officially broken and MD5 should not be considered a cryptographically secure hash anymore. It is however still impossible to find an input message that leads to a hash value: find X when only H(X) is known (and X doesn't have a pre-computed structure with at least one 128 byte block of precomputed data). There are no known pre-image attacks against MD5.

It is generally also possible to guess passwords using brute force or (augmented) dictionary attacks, to compare databases or to try and find password hashes in so called rainbow tables. If a match is found then it is computationally certain that the input has been found. Hash functions are also secure against collision attacks: finding X' so that H(X') = H(X) given H(X). So if an X is found it is computationally certain that it was indeed the input message. Otherwise you would have performed a collision attack after all. Rainbow tables can be used to speed up the attacks and there are specialized internet resources out there that will help you find a password given a specific hash.

It is of course possible to re-use the hash value H(X) to verify passwords that were generated on other systems. The only thing that the receiving system has to do is to store the result of a deterministic function F that takes H(X) as input. When X is given to the system then H(X) and therefore F can be recalculated and the results can be compared. In other words, it is not required to decrypt the hash value to just verify that a password is correct, and you can still store the hash as a different value.


重要的是使用密码哈希或PBKDF(基于密码的密钥派生函数)来代替MD5。这样的函数指定如何将盐和散列一起使用。这样就不会为相同的密码(来自其他用户或其他数据库)生成相同的散列。由于这个原因,密码哈希也不允许使用彩虹表,只要盐足够大并且正确随机。

Password hashes also contain a work factor (sometimes configured using an iteration count) that can significantly slow down attacks that try to find the password given the salt and hash value. This is important as the database with salts and hash values could be stolen. Finally, the password hash may also be memory-hard so that a significant amount of memory is required to calculate the hash. This makes it impossible to use special hardware (GPU's, ASIC's, FPGA's etc.) to allow an attacker to speed up the search. Other inputs or configuration options such as a pepper or the amount of parallelization may also be available to a password hash.

然而,它仍然允许任何人验证给定H(X)的密码,即使H(X)是密码哈希。密码哈希仍然是确定的,所以如果有人知道所有的输入和哈希算法本身,那么X可以用来计算H(X),并且-再说一次-结果可以进行比较。

常用的密码散列有bcrypt、scrypt和PBKDF2。还有各种形式的Argon2,它是最近密码哈希竞赛的赢家。在CrackStation上有一篇很好的关于密码安全的博文。


可以使对手无法执行哈希计算来验证密码是否正确。为此,可以使用胡椒作为密码散列的输入。或者,哈希值当然可以使用AES等密码和CBC或GCM等操作模式进行加密。然而,这需要独立存储秘密/密钥,并且比密码哈希有更高的访问要求。

不。MD5不是加密(尽管它可能被用作一些加密算法的一部分),它是一个单向哈希函数。作为转换的一部分,大部分原始数据实际上“丢失”了。

Think about this: An MD5 is always 128 bits long. That means that there are 2128 possible MD5 hashes. That is a reasonably large number, and yet it is most definitely finite. And yet, there are an infinite number of possible inputs to a given hash function (and most of them contain more than 128 bits, or a measly 16 bytes). So there are actually an infinite number of possibilities for data that would hash to the same value. The thing that makes hashes interesting is that it is incredibly difficult to find two pieces of data that hash to the same value, and the chances of it happening by accident are almost 0.

A simple example for a (very insecure) hash function (and this illustrates the general idea of it being one-way) would be to take all of the bits of a piece of data, and treat it as a large number. Next, perform integer division using some large (probably prime) number n and take the remainder (see: Modulus). You will be left with some number between 0 and n. If you were to perform the same calculation again (any time, on any computer, anywhere), using the exact same string, it will come up with the same value. And yet, there is no way to find out what the original value was, since there are an infinite number of numbers that have that exact remainder, when divided by n.

That said, MD5 has been found to have some weaknesses, such that with some complex mathematics, it may be possible to find a collision without trying out 2128 possible input strings. And the fact that most passwords are short, and people often use common values (like "password" or "secret") means that in some cases, you can make a reasonably good guess at someone's password by Googling for the hash or using a Rainbow table. That is one reason why you should always "salt" hashed passwords, so that two identical values, when hashed, will not hash to the same value.

一旦一段数据通过哈希函数运行,就没有回头路了。

MD5有它的弱点(见维基百科),所以有一些项目,试图预先计算哈希值。维基百科也暗示了其中一些项目。我所知道(并且尊敬)的一个是ophrack。您不能告诉用户他们自己的密码,但您可以告诉他们一个有效的密码。但我想:还是给他们寄个新密码吧,以防他们忘了。

是的,你所要求的一切都是可能的。 在没有帮助的情况下“解密”MD5密码是不可能的,但是可以将MD5密码重新加密到另一种算法中,只是不能一蹴而就。

您要做的就是让用户能够使用旧的MD5密码登录到新系统。在他们登录时,他们已经给了你的登录程序一个未加密的密码版本,你证明与你拥有的MD5哈希匹配。然后,您可以将这个非散列密码转换为新的散列算法。

显然,这是一个扩展的过程,因为您必须等待用户告诉您密码是什么,但它确实有效。

(注意:七年后,哦,希望有人会发现它有用)