Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function minus(){
- $x=rand(97,122);
- return chr($x);
- }
- function mayus(){
- $x=rand(65,90);
- return chr($x);
- }
- function numero(){
- $x=rand(48,57);
- return chr($x);
- }
- function simbol(){
- $x=rand(35,47);
- return chr($x);
- }
- $ok=false;
- while ($ok==false) {
- $aux=rand(8,12);
- $pwd='';
- for ($i=0; $i<$aux;$i++){
- $j=rand(0,3);
- if ($j==0) {
- $pwd=$pwd . minus();
- }
- if ($j==1) {
- $pwd=$pwd . mayus();
- }
- if ($j==2) {
- $pwd=$pwd . numero();
- }
- if ($j==3) {
- $pwd=$pwd . simbol();
- }
- }
- $ok=false;
- if (preg_match("/[A-Z]{1,}/", $pwd) &&
- preg_match("/[a-z]{1,}/", $pwd) &&
- preg_match("/[0-9]{1,}/", $pwd) &&
- preg_match("/[.'&()+]{1,}/", $pwd)) {
- $ok=true;
- }
- }
- echo $pwd;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement