Random Password Using PHP

Random Password Using PHP
A function that generates strong passwords by mixing uppercase and lowercase characters with numbers.
function RandPass($PassLength)
{
        $PassStr = "";
        for ($i = 0; $i <= $PassLength; $i++)
        {
                $CurrChar='';
                switch (mt_rand(1,3))
                {
                        case 1:
                                $CurrChar = chr(mt_rand(48,57));
                                break;
                        case 2:
                                $CurrChar = chr(mt_rand(65,90));
                                break;
                        case 3:
                                $CurrChar = chr(mt_rand(97,122));
                               
                }
                $PassStr .= $chr;
        }       
        return $PassStr;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top