function drush_generate_password

8.0.x drush.inc drush_generate_password($length = 10)
6.x drush.inc drush_generate_password($length = 10)
7.x drush.inc drush_generate_password($length = 10)
5.x drush.inc drush_generate_password($length = 10)
master drush.inc drush_generate_password($length = 10)

Generate a random alphanumeric password. Copied from user.module.

3 calls to drush_generate_password()
drush_core_site_install_version in commands/core/drupal/site_install_7.inc
Install Drupal 7
drush_core_site_install_version in commands/core/drupal/site_install_6.inc
Install Drupal 6.x
drush_core_site_install_version in commands/core/drupal/site_install.inc
Install Drupal 8+

File

includes/drush.inc, line 1692
The drush API implementation and helpers.

Code

function drush_generate_password($length = 10) {
  // This variable contains the list of allowable characters for the
  // password. Note that the number 0 and the letter 'O' have been
  // removed to avoid confusion between the two. The same is true
  // of 'I', 1, and 'l'.
  $allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';

  // Zero-based count of characters in the allowable list:
  $len = strlen($allowable_characters) - 1;

  // Declare the password as a blank string.
  $pass = '';

  // Loop the number of times specified by $length.
  for ($i = 0; $i < $length; $i++) {

    // Each iteration, pick a random character from the
    // allowable string and append it to the password:
    $pass .= $allowable_characters[mt_rand(0, $len)];
  }

  return $pass;
}