StyleGame

Online Tutorials

Va rog sa faceti cunoscut forumu. Cum puteti ajuta? De preferat la status pe yahoo messenger massuri etc. Va urez bafta in a ne ajuta cu respect echipa stylegame

    [PHP] Random readable password

    Distribuiţi
    avatar
    CYobY
    Administrator
    Administrator

    Mesaje : 197
    Data de inscriere : 04/10/2009
    Varsta : 24
    Localizare : VASLUI

    [PHP] Random readable password

    Mesaj Scris de CYobY la data de Sam Oct 24, 2009 6:25 pm

    Cod:
        function random_readable_pwd($length=10){

            // the wordlist from which the password
            // gets generated: (adjust them here:)
            $words = 'dog,cat,sheep,sun,sky,red,ball,happy,ice';
            $words .= 'green,blue,music,movies,radio,green,turbo';
            $words .= 'mouse,computer,paper,water,fire,storm,chicken';
            $words .= 'boot,freedom,white,nice,player,small,eyes';
            $words .= 'path,kid,box,black,flower,ping,pong,smile';
            $words .= 'coffee,colors,rainbow,plus,king,tv,ring';

            // explode by ",":
            $words = explode(',', $words);
            if (count($words) == 0){ die('Wordlist is empty!'); }

            mt_srand((double)microtime()*1000000);

            // while password is smaller than $length -> add
            // words:
            $pwd = '';
            while (strlen($pwd) <length> 2 and
            // reduce the password size to $length
            $num = mt_rand(1, 99);
            if ($length > 2){
                $pwd = substr($pwd,0,$length-strlen($num)).$num;
            } else {
                $pwd = substr($pwd, 0, $length);
            }

            return $pwd;

        }


    _________________
    RESPECT

      Subiecte similare

      -

      Acum este: Mar Sept 25, 2018 9:26 pm