Auto-generate password for a new member

Silverstripe Version: 4.x

Is there a way to auto-generate a password for a new member in SS4? The desired user flow:
-Person signs up to be a member.
-Member password is auto-generated
-Member data including password is saved to DB
-Welcome email sent, with initial login info including password
-On first login, member is required to change their password

A key goal is not to have the site admin manually add a password for a new member. Security/lostpassword will not help as the member record cannot be created without a password.

he SS3 create_new_password() function is deprecated; is there is any alternate function to do this?

Here it is:

function my_create_new_password()
    $random = mt_rand();
    $string = md5($random ?? '');
    $output = substr($string ?? '', 0, 8);
    return $output;

Thanks for this, works fine. However when I add a member manually in the Security > Add Member form, how can we auto-insert a password into the Password fields, so that the admin does not need to do that manually?