Simple password generator

By Toledoh - September 18, 2020

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)

By Deborah - September 19, 2020

Hi, Tim.

I have notes from 2010, but the original forum post is no longer available. I *think* I tried it, but can't be sure.

WAS:
$_REQUEST['password'] = substr(md5(uniqid(rand(), true)), 15);

FOR 4-CHARACTER PASSWORD, CHANGED TO:
$_REQUEST['password'] = substr(md5(uniqid(rand(), true)),0, 4);

Not only was the '15' changed to '4', but the '0,' was also added in front of it.

Hope that works for you.

~ Deborah

By Toledoh - September 19, 2020

Great Deborah, that worked - thanks!

Anyone have any ideas on making it purely numeric?

Cheers,

Tim (toledoh.com.au)

By Toledoh - September 23, 2020

Great - thanks for that Carl!

Cheers,

Tim (toledoh.com.au)