What is Drupal's default password encryption method?

后端 未结 5 1398
谎友^
谎友^ 2020-12-13 08:33

I am trying to figure out what is the security that Drupal 6/7 uses by default to store passwords. Is it MD5, AES, SHA? I have been unable to find anything.

5条回答
  •  佛祖请我去吃肉
    2020-12-13 09:23

    It can be checked inside www\includes\password.inc

    function user_check_password($password, $account) {
      if (substr($account->pass, 0, 2) == 'U$') {
        // This may be an updated password from user_update_7000(). Such hashes
        // have 'U' added as the first character and need an extra md5().
        $stored_hash = substr($account->pass, 1);
        $password = md5($password);
      }
      else {
        $stored_hash = $account->pass;
      }
    
      $type = substr($stored_hash, 0, 3);
      switch ($type) {
        case '$S$':
          // A normal Drupal 7 password using sha512.
          $hash = _password_crypt('sha512', $password, $stored_hash);
          break;
        case '$H$':
          // phpBB3 uses "$H$" for the same thing as "$P$".
        case '$P$':
          // A phpass password generated using md5.  This is an
          // imported password or from an earlier Drupal version.
          $hash = _password_crypt('md5', $password, $stored_hash);
          break;
        default:
          return FALSE;
      }
      return ($hash && $stored_hash == $hash);
    }
    

    Its been clearly written that "// A normal Drupal 7 password using sha512."

提交回复
热议问题