You are here

function _acquia_agent_hash_password_crypt in Acquia Connector 6.2

Same name and namespace in other branches
  1. 7.3 acquia_agent/acquia_agent.pages.inc \_acquia_agent_hash_password_crypt()
  2. 7.2 acquia_agent/acquia_agent.pages.inc \_acquia_agent_hash_password_crypt()

Hash a password according to Drupal's password_crypt and settings from remote.

1 call to _acquia_agent_hash_password_crypt()
acquia_agent_automatic_setup_form_validate in acquia_agent/acquia_agent.pages.inc

File

acquia_agent/acquia_agent.pages.inc, line 34
Acquia Agent configuration page.

Code

function _acquia_agent_hash_password_crypt($algorithm, $pass, $setting, $extra_md5 = FALSE) {

  // Server may state that password needs to be hashed with MD5 first.
  if ($extra_md5) {
    $pass = md5($pass);
  }

  // If module phpass exists include its password.inc, otherwise use the one
  // included with Acquia Agent (a copy of phpass' password.inc).
  if (module_exists('phpass')) {
    module_load_include('inc', 'phpass', 'password');
    $hash = _password_crypt($algorithm, $pass, $setting);
  }
  else {
    module_load_include('inc', 'acquia_agent', 'password');
    $hash = _password_crypt($algorithm, $pass, $setting);
  }

  // Match the hash stored on the server which has prefix character 'U' if
  // password was first hashed with MD5.
  if ($extra_md5) {
    $hash = 'U' . $hash;
  }
  return $hash;
}