/ Published in: PHP
Let' see the parameters
lenght: is the password length (default = 8)
use_upper: set to 0 if you do not want to use uppercase chars (ABCD...), any other value otherwise. Default = 1
use_lower: set to 0 if you do not want to use lowercase chars (abcd...), any other value otherwise. Default = 1
use_number: set to 0 if you do not want to use number chars (0123...), any other value otherwise. Default = 1
use_custom: a string representing any extra char you want (such as ?*_ ...). Default = empy string
lenght: is the password length (default = 8)
use_upper: set to 0 if you do not want to use uppercase chars (ABCD...), any other value otherwise. Default = 1
use_lower: set to 0 if you do not want to use lowercase chars (abcd...), any other value otherwise. Default = 1
use_number: set to 0 if you do not want to use number chars (0123...), any other value otherwise. Default = 1
use_custom: a string representing any extra char you want (such as ?*_ ...). Default = empy string
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function create_password($length=8,$use_upper=1,$use_lower=1,$use_number=1,$use_custom=""){ $upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $lower = "abcdefghijklmnopqrstuvwxyz"; $number = "0123456789"; if($use_upper){ $seed_length += 26; $seed .= $upper; } if($use_lower){ $seed_length += 26; $seed .= $lower; } if($use_number){ $seed_length += 10; $seed .= $number; } if($use_custom){ $seed .= $use_custom; } for($x=1;$x<=$length;$x++){ } return($password); } ?> USAGE: <?php echo create_password(); // Returns for example a7YmTwG4 echo create_password(16); // Returns for example Z77OzzS3DgV3OxxP echo create_password(8,0,0); // Returns for example 40714215 echo create_password(10,1,1,1,";,:.-_()"); // Returns for example or)ZA10kpX ?>