PHP: Generate a random password:
The followinf function will generate a random password. We just give total length of the password as input. For this we will print the function value, specifying the length of the password to be generated.
Code
The followinf function will generate a random password. We just give total length of the password as input. For this we will print the function value, specifying the length of the password to be generated.
Code
<?php <!-- --> function generateRandomPassword($cnt) { // characters to be included for randomization, $chars= str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@#%$*'); // Here specify the 2nd parameter as start position, it can be anything, default 0 return substr($chars,0,$cnt); } // Usage $password = generateRandomPassword(7); // specify the length of the generated password
echo "Your random password is:".$password;<!-- --> ?>
1 comments:
Thanks for ur code...It helped me........
Post a Comment
Share your thoughts here...