EasyPHPScripts.com      Free Open Source PHP Scripts and Code Snippet Library

 +Menu
+   Site News
+   Main Pages
+   Other Downloads
 +PHP
+ Arrays (9)
+ Directory And Files (7)
+ Image (3)
+ LDAP (3)
+ MySQL (11)
+ Other (11)
+ Dynamic Content
+ EasyPHPEmail
+ Function Basics
+ Get URL
+ Input Validation
+ RandPass
+ Random Field Name Genorator
+ Random Password
+ Redirect To
+ Set and Delete Cookies
+ Valid IP
+ Regular Expressions (3)
+ String Manipulation (13)
+ Time and Date (6)
 +Snippet Options
+   Printer Friendly
 +Library Options
+   View Other Library
 +General Options
+   Log in
Description for Snippet: Other / RandPass
  Unique chars and other chars besides aphla numeric.
 
Syntax for: RandPass

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
<?

function randpass($len=8){
    while(
1){
      switch(
rand(1,5)){
        case 
1$r =  rand(65,90); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //A-Z
        
case 2$r =  rand(48,57); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //0-9
        
case 3$r rand(97,122); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //a-z
        
case 4$r =  rand(33,47); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; 
        case 
5$r =  rand(58,64); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; 
      }
      if(
strlen($pw) == $len)  break;
    }
  return 
$pw;
}
?>
 


 
Powered by: PHP & centOS