繁体   English   中英

可以解密MD5密码吗?

[英]Is is possible to decrypt MD5 passwords?

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

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

别。 MD5不安全

我该如何加密这些密码,并像真实密码一样查看它们

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

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

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

用户登录时:

  1. 用户通过SSL向您发送密码
  2. 您对密码进行哈希处理
  3. 您将哈希密码与数据库中的哈希进行比较

只需将它们存储在加密的数据库中即可—就是为了这个目的。

生成密码:

$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...
}

关于密码和数据库的安全性,请注意让用户使用密码s is if he somehow acess the database itself (probably he got the password), so does it really make的唯一方法s is if he somehow acess the database itself (probably he got the password), so does it really make如果密码是散列或加密的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在Google的第一个结果搜索中找到了一个在线解密程序。 您对此有何看法? 先感谢您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM