-1

我想知道是否可以解密 MD5 密码

4

3 回答 3

4

我使用 md5 自动为用户生成密码

不。MD5 不安全

如何加密这些密码并将它们视为真实密码

我认为您的意思是“解密”。你不能。MD5 是一种散列算法,它被设计为不可逆的。

不要为您的用户生成密码。您的流程应该是:

  1. 用户生成密码
  2. 用户通过 SSL 向您发送密码
  3. 您对密码进行哈希处理(不使用 MD5)
  4. 您存储散列密码

当用户登录时:

  1. 用户通过 SSL 向您发送密码
  2. 你散列密码
  3. 您将哈希密码与数据库中的哈希值进行比较
于 2013-02-19T09:42:40.477 回答
1

只需将它们存储在加密的数据库中 - 这就是它的用途。

生成密码:

$characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
$your_password_length = 8;
$password_unencrypted = '';
for ($i = 0; $i < $your_password_length; $i++) {
  $password_unencrypted .= $characters[rand(0, strlen($characters) - 1)];
} 

现在加密它

$password_encrypted = md5($password_unencrypted);

现在您有两个变量 - password_unencrypted 和 password_encrypted。例如,您可以通过邮件将 password_unencrypted 发送给用户,但 DB 应包含加密密码。当用户登录时,您应该将他的加密输入与数据库中的加密密码进行比较:

//..get the md5 from DB to $password_encrypted and then
if (md5($_POST['users_password_in_form']) == $password_encrypted){
// ...log in...
}
于 2013-02-19T09:49:11.090 回答
1

s is if he somehow acess the database itself (probably he got the password), so does it really make关于密码和数据库安全,如果密码被散列或加密,那么用户可以访问密码差异的唯一方法是什么?我m asking cause we are trying to protect the user password, but if someone has acess to the database, he dont need the user password, he can make the changes on the database itself, and about the encrypting, i find on php manual that blowfish is the most indicated, but i在谷歌的第一个结果搜索中找到了一个在线解密器。你怎么看?先感谢您。

于 2013-04-10T16:08:24.057 回答