Simple password generator

Hi All.

Rather than the long long generated password created automatically via the membership sign-up, I'm wanting a really simple 4 digit code.

How would I change it? I'm guessing something with the following in websiteMembership.php?

function wsm_generatePassword() {
$password = substr(md5(uniqid(mt_rand(), true)), 15); // example output: c5560251ef0b3eef9
return $password;
}

Cheers,

Tim (toledoh.com.au)

Great Deborah, that worked - thanks!

Anyone have any ideas on making it purely numeric?

Cheers,

Tim (toledoh.com.au)

By Carl - September 23, 2020

Hi Toledoh,
You can see that the code snippet Deborah provided has md5 in it, which means the password returned is encrypted. That's what you will want when you're saving the password into the database. If you removed the md5 from the snippet, you would see 4 purely numeric values being returned.

Here's an example of a password being generated without the hash: 1197. 

Carl

PHP Programmer

interactivetools.com

Great - thanks for that Carl!

Cheers,

Tim (toledoh.com.au)