黄聪

论SEO对人类的重要性,请看我的博客:hcsem.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
function generatePassword($length=9, $strength=0) {   
        $vowels = 'aeuy';   
        $consonants = 'bdghjmnpqrstvz';   
        if ($strength >= 1) {   
            $consonants .= 'BDGHJLMNPQRSTVWXZ';   
        }   
        if ($strength >= 2) {   
            $vowels .= "AEUY";   
        }   
        if ($strength >= 4) {   
            $consonants .= '23456789';   
        }   
        if ($strength >= 8 ) {   
            $vowels .= '@#$%';   
        }   
       
        $password = '';   
        $alt = time() % 2;   
        for ($i = 0; $i < $length; $i++) {   
            if ($alt == 1) {   
                $password .= $consonants[(rand() % strlen($consonants))];   
                $alt = 0;   
            } else {   
                $password .= $vowels[(rand() % strlen($vowels))];   
                $alt = 1;   
            }   
        }   
        return $password;   
    }
posted on 2012-07-26 15:23  黄聪  阅读(324)  评论(0编辑  收藏  举报