簡體   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