In this tutorial,we will discuss how to generate random passwords using php functions. This applications is widely used in web application for registration purpose. The auto password is very helpful, and the hacker can’t easy to access our password because it include characters(a-z and A-Z), numbers(0-9) and special characters(!@#$%^&*()-=+?.).
The random password used for we application for users for security. And also we can specify the length of the password and these generated password can insert to database. For security we can insert the password to database using encryption method like sha1 or md5. Using PHP, it’s pretty easy to generate a random password.
We use str_shuffle function use for combine characters, numbers and special characters for generationgpassword. This function helps to randomly shuffles all the characters of a string.
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=+?";
$password = substr(str_shuffle( $chars ),0, $length );
$password = random_password_generate(8);
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.