What is Random Password Generate ?
Its Randomly Generated Secure Password Included with Alphabets in Upper & Lower Case, Numbers, Special Symbols !@#$ etc. These Passwords are not in Dictionary.
Method 1
<?php //Using String Concatenation and Random function password_generate_method1($length) { if (is_numeric($length) && $length <= 32 && $length > 7) { $str_alpha_up = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $str_alpha_small = "abcdefghijklmnopqrstuvwxyz"; $str_num = "1234567890"; $str_sym = "~!@#$%^&*()_'-\=+[];:<>,\/.?|"; $str = $str_alpha_up.$str_alpha_small.$str_num.$str_sym; $str_len = strlen($str) - 1; $pwd_str = ''; $pwd_len = 0; while ($pwd_len < $length) { $n = rand(0, $str_len); $pwd_str .= $str[$n]; $pwd_len = strlen($pwd_str); } return htmlentities($pwd_str); } else { return false; } } $pass = password_generate_method1(10); echo "<p> password $pass </p>"; ?>
Method 2
<?php //Using String Shuffled and SubString function password_generate_method2($length) { if (is_numeric($length)) { $string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $string .= "1234567890"; $string .= "~!@#$%^&*()_'-\=+[];:<>,\/.?|"; $shuffle = str_shuffle($string); $pwd_str = substr($shuffle, 0, $length); return htmlentities($pwd_str); } else { return false; } } $pass = password_generate_method2(10); echo "<p> password $pass </p>"; ?>
Method 3
//Using Short Function String Shuffled and SubString function password_generate_method3($length) { $data = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz'; $data .= '~!@#$%^&*()_-\=+[];:<>,\/.?|'; $password = substr(str_shuffle($data), 0, $length); return $password; } $pass = password_generate_method3(10); echo "<p> password $pass </p>";
Method 4
//Using Array function shuffle_assoc($my_array) { $keys = array_keys($my_array); shuffle($keys); foreach ($keys as $key) { $new[$key] = $my_array[$key]; } $my_array = $new; return $my_array; } function password_generate_method4($length) { if (is_numeric($length)) { $string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $string .= "1234567890"; $string .= "~!@#$%^&*()_'-\=+[];:<>,\/.?|"; $str_arr = str_split($string, 1); $shuffle = shuffle_assoc($str_arr); $pwd_str = implode("",array_slice($shuffle,0,$length)); return $pwd_str; } else { return false; } } $pass = password_generate_method4(10); echo "<p> password $pass </p>";
Online Generate
Random Password Generate Program
Demo
(Visited 152 times, 1 visits today)
Written by: