|
| | |
| Main » 2012 » November » 6 » How to generate a random password
10:16 PM How to generate a random password |
<?php class Randpass {
function
get_random_password($chars_min=6, $chars_max=8, $use_upper_case=false,
$include_numbers=false, $include_special_chars=false) { $length = rand($chars_min, $chars_max); $selection = 'aeuoyibcdfghjklmnpqrstvwxz'; if($include_numbers) { $selection .= "1234567890"; } if($include_special_chars) { $selection .= "!@\"#$%&[]{}?|"; } $password = ""; for($i=0; $i<$length; $i++) {
$current_letter = $use_upper_case ? (rand(0,1) ?
strtoupper($selection[(rand() % strlen($selection))]) :
$selection[(rand() % strlen($selection))]) : $selection[(rand() %
strlen($selection))]; $password .= $current_letter; } return $password; } } //call the function $obj = new Randpass(); $getpassword=$obj->get_random_password(); //you can pass the parameters with overrite the values ?>
|
Category: Web Development |
Views: 584 |
Added by: admin-priyank
| Rating: 5.0/1 |
| |
| | |
|
Calendar |
| « November 2012 » | Su | Mo | Tu | We | Th | Fr | Sa | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| |
|
Our poll |
| | |
|
Statistics |
|
Total online: 6 Guests: 6 Users: 0 | |
|
|