Create password and send email

Hello Guys!

I would like to create a user with a random password, generated by wappler, and then send it via e-mail, with the welcome message. On the first access I will force user to change the password.

I didn’t found a “random” function on server connect and I don’t know how to get the random generated password before the encrypt process.

Thanks! Have a great week!

While not random per se, I take a timestamp and add it to the username, then hash it with a salt and take the first 8 characters.

(TIMESTAMP + $_POST.username).sha256("some-random-string-fjDFef
ghw5^^48&&*dDSe").substr(0, 8)

If you hash the timestamp once, take that as the new password (or first 8-12 chars of it), then hash that with a salt to store it, you’re about as random as it gets.

I would get the timestamp, do an MD5 hash of it, get the first 8-12 chars and make that their random password. Then store it with the sha156 + salt in the database.

Or is that what you suggested @mebeingken? If so, that’s pretty random to me!

Thanks @sitestreet and @mebeingken both solutions are great! I used timestamps + MD5Hash!

1 Like