Function __global->get_secure_random_password

Definitions

sources/crypt.php

  • Generate a cryptographically-secure pseudo-random password using uppercase letters, lowercase letters, numbers, and symbols.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$strength ?integer No No Null N/A N/A The minimum password strength we want; the generated password could be stronger but will never be weaker (null: use configured strength)
$username SHORT_TEXT No No Blank (empty string) N/A N/A The username of the member for which we are generating a password (blank: do not check username in password strength check)
$email_address SHORT_TEXT No No Blank (empty string) N/A N/A The e-mail address of the member (blank: do not check e-mail address in password strength check)
$dob ?TIME No No Null N/A N/A The date of birth of the member (null: do not check dob in password strength check)

Returns

  • The random password
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Generate a cryptographically-secure pseudo-random password using uppercase letters, lowercase letters, numbers, and symbols.
 *
 * @param  ?integer $strength The minimum password strength we want; the generated password could be stronger but will never be weaker (null: use configured strength)
 * @param  SHORT_TEXT $username The username of the member for which we are generating a password (blank: do not check username in password strength check)
 * @param  SHORT_TEXT $email_address The e-mail address of the member (blank: do not check e-mail address in password strength check)
 * @param  ?TIME $dob The date of birth of the member (null: do not check dob in password strength check)
 * @return string The random password
 */

function get_secure_random_password(?int $strength = null, string $username = '', string $email_address = '', ?int $dob = null) : string